-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphysijsView.js
More file actions
47 lines (35 loc) · 1.45 KB
/
physijsView.js
File metadata and controls
47 lines (35 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"use strict";
// For conditions of distribution and use, see copyright notice in LICENSE
/*
* @author Tapani Jamsa
* Date: 2014
*/
function PhysijsView() {
Tundra.ThreeView.call(this); // call super constructor.
Physijs.scripts.worker = 'physijs_worker.js';
Physijs.scripts.ammo = 'ammo.js';
this.componentRemovedSig.add(function(component) {
if (component.parentEntity.boxMesh) {
// 'if' inside 'if' because we don't want to call threeGroup.parent.remove(threeGroup);
if (component.parentEntity.boxMesh.parent) {
component.parentEntity.boxMesh.parent.remove(component.parentEntity.boxMesh);
}
}
});
}
PhysijsView.prototype = Object.create(Tundra.ThreeView.prototype);
PhysijsView.prototype.constructor = PhysijsView;
PhysijsView.prototype.onComponentAddedOrChanged = function(entity, component,changeType, changedAttr) {
Tundra.ThreeView.prototype.onComponentAddedOrChanged.call(this, entity, component, changeType, changedAttr);
if (component instanceof Tundra.EC_RigidBody)
this.onRigidBodyAddedOrChanged(entity, component);
};
PhysijsView.prototype.onRigidBodyAddedOrChanged = function(entity, rigidBodyComponent) {
var prevPhysiMesh = rigidBodyComponent.physiMesh;
if (prevPhysiMesh) {
console.log("unhandled prev physijs mesh");
}
};
PhysijsView.prototype.createScene = function() {
return new Physijs.Scene();
};