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 colors = []; for (var i = 0; i < this.boxGeometry.instance.index.count; i++) { colors.push(1, 1, 1); } this.boxGeometry.instance.addAttribute('color', new THREE.Float32BufferAttribute(colors, 3)); var heightData = this.imageSpoon.getHeightData(); var instances = 16384; //128 x 128 var x, y = 0; var positions = []; var quaternions = []; 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; positions.push(x - 64, 64 - y, height); quaternions.push(0, 0, 0, 1); scales.push(scale, scale, scale); } } this.instancedGeometry.instance.attributes.position = this.boxGeometry.instance.attributes.position; //this.instancedGeometry.instance.attributes.position = this.boxGeometry.instance.attributes.position; //this.instancedGeometry.instance.attributes.color = this.boxGeometry.instance.attributes.color; 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