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.initialized = true; console.log('key up 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.1; offsets.push((x - 64) * 2, (64 - y) * 2, height); orientations.push(0, 0, 0, 1); //scales.push(scale, scale, scale); } } 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.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); this.instancedGeometry.instance.addAttribute('offset', offsetAttribute); this.instancedGeometry.instance.addAttribute('orientation', orientationAttribute); // 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'); } //@ sourceURL=ccKeyUp.js