43 lines
952 B
JavaScript
43 lines
952 B
JavaScript
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.instancedGeometry = this.entityLoaded.instancedGeometry;
|
|
|
|
this.instancedGeometry.instance.attributes.position = this.boxGeometry.instance.attributes.position;
|
|
|
|
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 positions = [];
|
|
|
|
for (x = 0; x < 128; x++) {
|
|
for (y = 0; y < 128; y++) {
|
|
positions.push(x, y, heightData[(x * y) + x + y]);
|
|
}
|
|
}
|
|
|
|
this.instancedGeometry.instance.addAttribute('instancePosition', new THREE.InstancedBufferAttribute( new Float32Array(positions), 3));
|
|
|
|
console.log('got data');
|
|
}
|
|
|
|
//@ sourceURL=ccKeyUp.js
|