From 8a932fc9e04da79908ed703882eb9bd5c4fa509a Mon Sep 17 00:00:00 2001 From: "Theunis J. Botha" Date: Mon, 5 Dec 2016 16:40:26 +0100 Subject: [PATCH] start to dig into common objects --- src/game-lib-material.js | 21 ++++++++++----------- src/game-lib-vector3.js | 14 +++++++------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/game-lib-material.js b/src/game-lib-material.js index 5ff95a4..91a93cb 100644 --- a/src/game-lib-material.js +++ b/src/game-lib-material.js @@ -279,19 +279,18 @@ GameLib.D3.Material.prototype.createInstance = function(update) { if (update) { for (var property in instance) { - - if (property == 'size') { - instance[property] = this.pointSize; - } - - if (property == 'sizeAttenuation') { - instance[property] = this.pointSizeAttenuation; - } - if ( - this.hasOwnProperty(property) && - instance.hasOwnProperty(property) + instance.hasOwnProperty(property) && + this.hasOwnProperty(property) ) { + if (property == 'size') { + instance[property] = this.pointSize; + } + + if (property == 'sizeAttenuation') { + instance[property] = this.pointSizeAttenuation; + } + if (instance[property] instanceof THREE.Color) { instance[property].copy(this[property]) } else { diff --git a/src/game-lib-vector3.js b/src/game-lib-vector3.js index c72ea2e..be480cb 100644 --- a/src/game-lib-vector3.js +++ b/src/game-lib-vector3.js @@ -1,16 +1,16 @@ /** - * Runtime vector3 for updating instance objects + * Runtime apiVector3 for updating instance objects * @param graphics GameLib.D3.Graphics * @param parentObject GameLib.D3.* - * @param vector3 GameLib.D3.API.Vector3 + * @param apiVector3 GameLib.D3.API.Vector3 * @param grain Number * @constructor */ -GameLib.D3.Vector3 = function RuntimeVector3(graphics, parentObject, vector3, grain) { +GameLib.D3.Vector3 = function RuntimeVector3(graphics, parentObject, apiVector3, grain) { - for (var property in vector3) { - if (vector3.hasOwnProperty(property)) { - this[property] = vector3[property]; + for (var property in apiVector3) { + if (apiVector3.hasOwnProperty(property)) { + this[property] = apiVector3[property]; } } @@ -45,7 +45,7 @@ GameLib.D3.Vector3.prototype.createInstance = function(update) { instance.y = this.y; instance.z = this.z; } else { - instance = new this.graphics.instance.Vector3(this.x, this.y, this.z); + instance = new THREE.Vector3(this.x, this.y, this.z); } return instance;