Update: CC - Demo New - Entity Loaded (tuby5lj4di.js) 570 bytes modified

beta.r3js.org
-=yb4f310 2018-02-16 11:34:19 +01:00
parent 299f539a2e
commit ea9fcd03a7
1 changed files with 85 additions and 74 deletions

View File

@ -40,11 +40,13 @@ this.materialRawPhong = GameLib.EntityManager.Instance.findComponentById('r153c4
/** /**
* Custom Code Components * Custom Code Components
*/ */
this.ccBeforeRender = GameLib.EntityManager.Instance.findComponentById('wlw063ovw9'); this.beforeRender = GameLib.EntityManager.Instance.findComponentById('wlw063ovw9');
this.ccKeyUp = GameLib.EntityManager.Instance.findComponentById('ip0443a52d'); this.keyUp = GameLib.EntityManager.Instance.findComponentById('ip0443a52d');
this.ccBeforeRender.entityLoaded = this; /**
this.ccKeyUp.entityLoaded = this; * Program parameters
*/
this.attributeData = null;
/** /**
* Generates new Attribute Data based on the image index according to 'width' and 'height' * Generates new Attribute Data based on the image index according to 'width' and 'height'
@ -82,7 +84,7 @@ GameLib.CustomCode.prototype.generateAttributeData = function(index, width, heig
*/ */
GameLib.CustomCode.prototype.buildInstancedGeometry = function(index) { GameLib.CustomCode.prototype.buildInstancedGeometry = function(index) {
var attributeData = this.generateAttributeData(index, 128, 128); this.attributeData = this.generateAttributeData(index, 128, 128);
var uniforms = Object.assign( var uniforms = Object.assign(
THREE.UniformsLib['lights'], THREE.UniformsLib['lights'],
@ -107,17 +109,17 @@ GameLib.CustomCode.prototype.buildInstancedGeometry = function(index) {
this.instancedGeometry.instance.attributes.uv = this.boxGeometry.instance.attributes.uv; this.instancedGeometry.instance.attributes.uv = this.boxGeometry.instance.attributes.uv;
var offsetAttribute = new THREE.InstancedBufferAttribute( var offsetAttribute = new THREE.InstancedBufferAttribute(
new Float32Array(attributeData.offsets), new Float32Array(this.attributeData.offsets),
3 3
).setDynamic(true); ).setDynamic(true);
var orientationAttribute = new THREE.InstancedBufferAttribute( var orientationAttribute = new THREE.InstancedBufferAttribute(
new Float32Array(attributeData.orientations), new Float32Array(this.attributeData.orientations),
4 4
); );
var scaleAttribute = new THREE.InstancedBufferAttribute( var scaleAttribute = new THREE.InstancedBufferAttribute(
new Float32Array(attributeData.scales), new Float32Array(this.attributeData.scales),
3 3
).setDynamic(true); ).setDynamic(true);
@ -127,6 +129,15 @@ GameLib.CustomCode.prototype.buildInstancedGeometry = function(index) {
}.bind(this); }.bind(this);
GameLib.CustomCode.prototype.startAnimation = function(attributeData) {
this.beforeRender.currentAttributeData = this.attributeData;
this.beforeRender.freshAttributeData = attributeData;
this.beforeRender.animate = true;
}.bind(this);
this.buildInstancedGeometry(0); this.buildInstancedGeometry(0);
this.beforeRender.entityLoaded = this;
this.keyUp.entityLoaded = this;
//@ sourceURL=entiyLoaded.js //@ sourceURL=entiyLoaded.js