update instance for mesh

beta.r3js.org
-=yb4f310 2017-11-27 00:09:10 +01:00
parent e4a5554c56
commit b5e55136b9
3 changed files with 117 additions and 97 deletions

12
build/game-lib-min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
// COMPILE TIME DEFINITIONS (Generated via gulp)
var __DATE__ = "Sat Nov 25 2017 11:12:58 GMT+0100 (CET)";
var __DATE__ = "Sun Nov 26 2017 22:50:32 GMT+0100 (CET)";
// END COMPILE TIME DEFINITIONS
/**
@ -14041,64 +14041,74 @@ GameLib.D3.Mesh.prototype.createInstance = function() {
*/
GameLib.D3.Mesh.prototype.updateInstance = function(property) {
if (( this.isBufferMesh && !(this.instance.geometry instanceof THREE.BufferGeometry)) ||
( !this.isBufferMesh && (this.instance.geometry instanceof THREE.BufferGeometry)))
{
/**
* The buffer geometry needs updating
*/
this.instance.geometry = this.createInstanceGeometry(this.instance.geometry);
}
if (this.useQuaternion) {
if (this.updateRotationFromAxisAngle) {
this.updateInstanceRotationFromAxisAngle();
} else {
this.instance.quaternion.x = this.quaternion.x;
this.instance.quaternion.y = this.quaternion.y;
this.instance.quaternion.z = this.quaternion.z;
this.instance.quaternion.w = this.quaternion.w;
}
} else {
this.instance.rotation.x = this.rotation.x;
this.instance.rotation.y = this.rotation.y;
this.instance.rotation.z = this.rotation.z;
if (GameLib.Utils.UndefinedOrNull(property)) {
console.warn('unknown mesh property update');
}
if (this.parentMesh && this.parentMesh.instance) {
if (this.instance.parent !== this.parentMesh.instance) {
this.instance.parent = this.parentMesh.instance;
}
}
if (property === 'isBufferMesh') {
if (( this.isBufferMesh && !(this.instance.geometry instanceof THREE.BufferGeometry)) ||
( !this.isBufferMesh && (this.instance.geometry instanceof THREE.BufferGeometry)))
{
/**
* The buffer geometry needs updating
*/
this.instance.geometry = this.createInstanceGeometry(this.instance.geometry);
}
}
this.instance.scale.x = this.scale.x;
this.instance.scale.y = this.scale.y;
this.instance.scale.z = this.scale.z;
if (
property === 'rotation' ||
property === 'quaternion' ||
property === 'useQuaternion'
) {
this.updateInstanceRotation();
}
this.instance.position.x = this.position.x;
this.instance.position.y = this.position.y;
this.instance.position.z = this.position.z;
if (property === 'parentMesh') {
if (this.parentMesh && this.parentMesh.instance) {
if (this.instance.parent !== this.parentMesh.instance) {
this.instance.parent = this.parentMesh.instance;
}
}
}
this.instance.up.x = this.up.x;
this.instance.up.y = this.up.y;
this.instance.up.z = this.up.z;
if (property === 'scale') {
this.updateInstanceScale();
}
this.instance.name = this.name;
if (property === 'position') {
this.updateInstancePosition();
}
if (this.materials.length === 1 && this.materials[0].instance) {
this.instance.material = this.materials[0].instance;
}
if (property === 'up') {
this.instance.up.x = this.up.x;
this.instance.up.y = this.up.y;
this.instance.up.z = this.up.z;
}
this.instance.renderOrder = this.renderOrder;
if (property === 'name') {
this.instance.name = this.name;
}
if (this.helper) {
if (property === 'materials') {
if (this.materials.length === 1 && this.materials[0].instance) {
this.instance.material = this.materials[0].instance;
}
}
if (property === 'renderOrder') {
this.instance.renderOrder = this.renderOrder;
}
if (property === 'visible') {
this.instance.visible = this.visible;
}
if (this.helper) {
this.removeHelper();
this.createHelper();
}
if (property === 'visible') {
this.instance.visible = this.visible;
}
};
/**

View File

@ -564,64 +564,74 @@ GameLib.D3.Mesh.prototype.createInstance = function() {
*/
GameLib.D3.Mesh.prototype.updateInstance = function(property) {
if (( this.isBufferMesh && !(this.instance.geometry instanceof THREE.BufferGeometry)) ||
( !this.isBufferMesh && (this.instance.geometry instanceof THREE.BufferGeometry)))
{
/**
* The buffer geometry needs updating
*/
this.instance.geometry = this.createInstanceGeometry(this.instance.geometry);
}
if (this.useQuaternion) {
if (this.updateRotationFromAxisAngle) {
this.updateInstanceRotationFromAxisAngle();
} else {
this.instance.quaternion.x = this.quaternion.x;
this.instance.quaternion.y = this.quaternion.y;
this.instance.quaternion.z = this.quaternion.z;
this.instance.quaternion.w = this.quaternion.w;
}
} else {
this.instance.rotation.x = this.rotation.x;
this.instance.rotation.y = this.rotation.y;
this.instance.rotation.z = this.rotation.z;
if (GameLib.Utils.UndefinedOrNull(property)) {
console.warn('unknown mesh property update');
}
if (this.parentMesh && this.parentMesh.instance) {
if (this.instance.parent !== this.parentMesh.instance) {
this.instance.parent = this.parentMesh.instance;
}
}
if (property === 'isBufferMesh') {
if (( this.isBufferMesh && !(this.instance.geometry instanceof THREE.BufferGeometry)) ||
( !this.isBufferMesh && (this.instance.geometry instanceof THREE.BufferGeometry)))
{
/**
* The buffer geometry needs updating
*/
this.instance.geometry = this.createInstanceGeometry(this.instance.geometry);
}
}
this.instance.scale.x = this.scale.x;
this.instance.scale.y = this.scale.y;
this.instance.scale.z = this.scale.z;
if (
property === 'rotation' ||
property === 'quaternion' ||
property === 'useQuaternion'
) {
this.updateInstanceRotation();
}
this.instance.position.x = this.position.x;
this.instance.position.y = this.position.y;
this.instance.position.z = this.position.z;
if (property === 'parentMesh') {
if (this.parentMesh && this.parentMesh.instance) {
if (this.instance.parent !== this.parentMesh.instance) {
this.instance.parent = this.parentMesh.instance;
}
}
}
this.instance.up.x = this.up.x;
this.instance.up.y = this.up.y;
this.instance.up.z = this.up.z;
if (property === 'scale') {
this.updateInstanceScale();
}
this.instance.name = this.name;
if (property === 'position') {
this.updateInstancePosition();
}
if (this.materials.length === 1 && this.materials[0].instance) {
this.instance.material = this.materials[0].instance;
}
if (property === 'up') {
this.instance.up.x = this.up.x;
this.instance.up.y = this.up.y;
this.instance.up.z = this.up.z;
}
this.instance.renderOrder = this.renderOrder;
if (property === 'name') {
this.instance.name = this.name;
}
if (this.helper) {
if (property === 'materials') {
if (this.materials.length === 1 && this.materials[0].instance) {
this.instance.material = this.materials[0].instance;
}
}
if (property === 'renderOrder') {
this.instance.renderOrder = this.renderOrder;
}
if (property === 'visible') {
this.instance.visible = this.visible;
}
if (this.helper) {
this.removeHelper();
this.createHelper();
}
if (property === 'visible') {
this.instance.visible = this.visible;
}
};
/**