diff --git a/ip0443a52d.js b/ip0443a52d.js index 612130f..8e487d7 100644 --- a/ip0443a52d.js +++ b/ip0443a52d.js @@ -2,21 +2,9 @@ if (!this.entityLoaded) { return; } -this.initialized = false; - if (!this.initialized) { - this.imageSpoon = this.entityLoaded.imageSpoon; - this.imageEarth = this.entityLoaded.imageEarth; - - this.meshBox = this.entityLoaded.meshBox; - this.meshImageGrid = this.entityLoaded.meshImageGrid; - - this.boxGeometry = this.entityLoaded.boxGeometry; - this.instancedGeometry = this.entityLoaded.instancedGeometry; - - this.textureWhite = this.entityLoaded.textureWhite; - this.materialRawPhong = this.entityLoaded.materialRawPhong; + this.currentImageIndex = 0; this.initialized = true; @@ -24,95 +12,16 @@ if (!this.initialized) { } if (data.code === 'KeyL') { - - var heightData = this.imageSpoon.getHeightData(); - - var instances = 16384; //128 x 128 - - var x, y = 0; - - var offsets = []; - var orientations = []; - var scales = []; - - var height = 0; - - for (x = 0; x < 128; x++) { - for (y = 0; y < 128; y++) { - - height = heightData[(y * 128) + x] * 10; - scale = height * 0.19; - - offsets.push((x - 64) * 2, (64 - y) * 2, height); - orientations.push(0, 0, 0, 1); - scales.push(scale, scale, scale); - } - } - - var uniforms = Object.assign( - THREE.UniformsLib['lights'], - THREE.UniformsLib['common'], - { - map : { - value : this.textureWhite.instance - } - } - ); - - uniforms.opacity.value = 0.2; - uniforms.diffuse.value.r = 0.47; - uniforms.diffuse.value.g = 0.72; - uniforms.diffuse.value.b = 1.0; - - this.materialRawPhong.instance.uniforms = uniforms; - - this.instancedGeometry.instance.index = this.boxGeometry.instance.index; - this.instancedGeometry.instance.groups = this.boxGeometry.instance.groups; - this.instancedGeometry.instance.attributes.position = this.boxGeometry.instance.attributes.position; - this.instancedGeometry.instance.attributes.normal = this.boxGeometry.instance.attributes.normal; - this.instancedGeometry.instance.attributes.uv = this.boxGeometry.instance.attributes.uv; - - var offsetAttribute = new THREE.InstancedBufferAttribute( - new Float32Array(offsets), - 3 - ); - - var orientationAttribute = new THREE.InstancedBufferAttribute( - new Float32Array(orientations), - 4 - ).setDynamic(true); - - var scaleAttribute = new THREE.InstancedBufferAttribute( - new Float32Array(scales), - 3 - ); - - this.instancedGeometry.instance.addAttribute('offset', offsetAttribute); - this.instancedGeometry.instance.addAttribute('orientation', orientationAttribute); - this.instancedGeometry.instance.addAttribute('scale', scaleAttribute); - - - // this.instancedGeometry.instance.removeAttribute('color'); -// this.instancedGeometry.instance.removeAttribute('instancePosition'); -// this.instancedGeometry.instance.removeAttribute('instanceQuaternion'); -// this.instancedGeometry.instance.removeAttribute('instanceScale'); - -// this.instancedGeometry.instance.addAttribute('instancePosition', new THREE.InstancedBufferAttribute( new Float32Array(positions), 3)); -// this.instancedGeometry.instance.addAttribute('instanceQuaternion', new THREE.InstancedBufferAttribute( new Float32Array(quaternions), 4)); -// this.instancedGeometry.instance.addAttribute('instanceScale', new THREE.InstancedBufferAttribute( new Float32Array(scales), 3)); - -// this.instancedGeometry.instance.addAttribute('color', new THREE.Float32BufferAttribute(colors, 3)); - - //this.instancedGeometry.instance.clearGroups(); - - //this.instancedGeometry.instance.addGroup(0, 36, 0); - - //this.meshImageGrid.geometry.instance = this.instancedGeometry.instance; - - //this.meshImageGrid.materials[0].createInstance(); - //this.meshImageGrid.updateInstance('materials'); - console.log('got data'); + if (this.currentImageIndex === this.images.length) { + this.currentImageIndex = 0; + }; + + var attributeData = this.generateAttributeData(this.currentImageIndex, 128, 128); + + this.currentImageIndex++; + + this.startAnimation(attributeData); } //@ sourceURL=ccKeyUp.js \ No newline at end of file