repo: janusweb action: commit revision: path_from: revision_from: d22c902e9d551ad48c72370cef561d2010bb9281: path_to: revision_to:
commit d22c902e9d551ad48c72370cef561d2010bb9281 Author: James BaicoianuDate: Thu Oct 19 22:32:28 2017 -0700 Moved collision attributes into janusbase class diff --git a/scripts/object.js b/scripts/object.js
--- a/scripts/object.js
+++ b/scripts/object.js
@@ -21,11 +21,6 @@ elation.require(['janusweb.janusbase', 'janusweb.websurface'], function() {
cull_face: { type: 'string', default: 'back', set: this.updateMaterial },
blend_src: { type: 'string', default: 'src_alpha', set: this.updateMaterial },
blend_dest: { type: 'string', default: 'one_minus_src_alpha', set: this.updateMaterial },
- collision_id: { type: 'string', set: this.updateCollider },
- collision_pos: { type: 'vector3', default: new THREE.Vector3(0,0,0), set: this.updateCollider },
- collision_scale: { type: 'vector3', set: this.updateCollider },
- collision_static: { type: 'boolean', default: true, set: this.updateCollider },
- collision_trigger: { type: 'boolean', default: false, set: this.updateCollider },
envmap_id: { type: 'string', set: this.updateMaterial },
});
//elation.events.add(this, 'thing_init3d', elation.bind(this, this.assignTextures));
@@ -67,67 +62,6 @@ elation.require(['janusweb.janusbase', 'janusweb.websurface'], function() {
if (!this.collidable) return;
this.updateCollider();
}
- this.updateCollider = function() {
- this.removeCollider();
- if (!this.collidable || !this.objects['dynamics']) return;
- var collision_id = this.collision_id || this.collider_id;
- var collision_scale = this.properties.collision_scale || this.properties.scale;
- if (collision_id) {
- if ((!this.collision_static || this.collision_static == 'false') && this.room.gravity) { // FIXME - should never receive 'false' as a string here
- this.objects.dynamics.mass = this.mass = 1;
- this.objects.dynamics.addForce('static', new THREE.Vector3(0, this.room.gravity, 0));
- }
-
- this.collidable = true;
- if (collision_id == 'sphere') {
- this.setCollider('sphere', {radius: Math.max(collision_scale.x, collision_scale.y, collision_scale.z) / 2, offset: this.collision_pos});
- } else if (collision_id == 'cube') {
- var halfsize = collision_scale.clone().multiplyScalar(.5);
- this.setCollider('box', {min: halfsize.clone().negate().add(this.collision_pos), max: halfsize.add(this.collision_pos)});
- } else if (collision_id == 'plane') {
- var halfsize = collision_scale.clone().multiplyScalar(.5).add(this.collision_pos);
- halfsize.z = .1;
- this.setCollider('box', {min: halfsize.clone().negate(), max: halfsize});
- } else if (collision_id == 'cylinder') {
- this.setCollider('cylinder', {height: 1, radius: .5, offset: new THREE.Vector3(0, 0.5, 0)});
- } else {
- var colliderasset = this.getAsset('model', collision_id);
- if (colliderasset) {
- var collider = colliderasset.getInstance();
- this.collidermesh = collider;
- if (collider.userData.loaded) {
- this.extractColliders(collider, true);
- collider.userData.thing = this;
- this.colliders.add(collider);
- } else {
- elation.events.add(collider, 'asset_load', elation.bind(this, function(ev) {
- collider.userData.thing = this;
- this.extractColliders(collider, true);
-
- //collider.bindPosition(this.position);
- //collider.bindQuaternion(this.orientation);
- //collider.bindScale(this.properties.scale);
-
- collider.traverse(elation.bind(this, function(n) {
- if (n.material) n.material = new THREE.MeshLambertMaterial({color: 0x999900, opacity: .2, transparent: true, emissive: 0x444400, alphaTest: .01, depthTest: false, depthWrite: false});
- n.userData.thing = this;
- }));
- this.colliders.add(collider);
-
- }) );
- }
- }
- }
- }
- }
- this.removeCollider = function() {
- if (this.colliders) {
- for (var i = 0; i < this.colliders.children.length; i++) {
- var collider = this.colliders.children[i];
- collider.parent.remove(collider);
- }
- }
- }
this.createObjectDOM = function() {
/*
if (this.websurface_id) {
@@ -665,12 +599,6 @@ elation.require(['janusweb.janusbase', 'janusweb.websurface'], function() {
blend_src: [ 'property', 'blend_src' ],
blend_dest: [ 'property', 'blend_dest' ],
- collision_id: [ 'property', 'collision_id'],
- collision_pos: [ 'property', 'collision_pos' ],
- collision_scale: [ 'property', 'collider_scale'],
- collision_static: [ 'property', 'collision_static'],
- collision_trigger: [ 'property', 'collision_trigger'],
-
// vide properties/functions
current_time: [ 'accessor', 'getCurrentTime'],
total_time: [ 'accessor', 'getTotalTime'],
-----END OF PAGE-----