beta.r3js.org
parent
7106e3368a
commit
7611567b2c
|
@ -16,7 +16,9 @@ code += '\tR3.API.Component.call(\n';
|
|||
code += '\t\tthis,\n';
|
||||
code += '\t\tthis.apiComponent.parent,\n';
|
||||
code += '\t\tthis.apiComponent.id,\n';
|
||||
code += '\t\tthis.apiComponent.name\n';
|
||||
code += '\t\tthis.apiComponent.name,\n';
|
||||
code += '\t\tthis.apiComponent.register,\n';
|
||||
code += '\t\tthis.apiComponent.selected\n';
|
||||
code += '\t)';
|
||||
|
||||
var code2 = 'if (R3.Utils.UndefinedOrNull(apiGeometryBuffer)) {\n';
|
||||
|
|
|
@ -2,11 +2,7 @@
|
|||
* Event Core
|
||||
* @constructor
|
||||
*/
|
||||
R3.Event = function(parent) {
|
||||
if (!parent) {
|
||||
parent = null;
|
||||
}
|
||||
this.parent = parent;
|
||||
R3.Event = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -143,6 +139,7 @@ R3.Event.GET_WEBSOCKET_CONFIG = 0x79;
|
|||
R3.Event.GET_PROJECT = 0x7a;
|
||||
R3.Event.GET_APPLICATION_MODE = 0x80;
|
||||
R3.Event.RENDERER_SIZE_CHANGE = 0x81;
|
||||
R3.Event.GET_REGISTER_FACES = 0x82;
|
||||
|
||||
/**
|
||||
* Returns string name of event ID
|
||||
|
@ -277,6 +274,7 @@ R3.Event.GetEventName = function(number) {
|
|||
case 0x7a : return 'get_project';
|
||||
case 0x80 : return 'get_application_mode';
|
||||
case 0x81 : return 'renderer_size_change';
|
||||
case 0x82 : return 'get_register_faces';
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,12 +3,16 @@
|
|||
* @param parent
|
||||
* @param id
|
||||
* @param name
|
||||
* @param register
|
||||
* @param selected
|
||||
* @constructor
|
||||
*/
|
||||
R3.API.Component = function(
|
||||
parent,
|
||||
id,
|
||||
name
|
||||
name,
|
||||
register,
|
||||
selected
|
||||
) {
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(parent)) {
|
||||
|
@ -27,6 +31,16 @@ R3.API.Component = function(
|
|||
name = R3.Component.GetComponentFriendlyName(this.componentType) + ' (' + this.id + ')';
|
||||
}
|
||||
this.name = name;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(register)) {
|
||||
register = true;
|
||||
}
|
||||
this.register = register;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(selected)) {
|
||||
selected = false;
|
||||
}
|
||||
this.selected = selected;
|
||||
};
|
||||
|
||||
R3.API.Component.prototype.constructor = R3.API.Component;
|
||||
|
|
|
@ -1,17 +1,11 @@
|
|||
/**
|
||||
* R3.Component is an R3.Event
|
||||
* @param parent
|
||||
* @param linkedObjects
|
||||
* @constructor
|
||||
*/
|
||||
R3.Component = function(
|
||||
parent,
|
||||
linkedObjects
|
||||
) {
|
||||
if (R3.Utils.UndefinedOrNull(parent)) {
|
||||
parent = null;
|
||||
}
|
||||
this.parent = parent;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(linkedObjects)) {
|
||||
linkedObjects = {};
|
||||
|
@ -21,17 +15,12 @@ R3.Component = function(
|
|||
/**
|
||||
* Call the Event constructor first so we can set the parent right away
|
||||
*/
|
||||
R3.Event.call(
|
||||
this,
|
||||
this.parent
|
||||
);
|
||||
R3.Event.call(this);
|
||||
|
||||
this.componentType = this.getComponentType();
|
||||
|
||||
this.idToObject = {};
|
||||
|
||||
this.selected = false;
|
||||
|
||||
this.building = false;
|
||||
|
||||
this.loaded = false;
|
||||
|
@ -46,12 +35,14 @@ R3.Component = function(
|
|||
|
||||
this.dependencies = this.getDependencies();
|
||||
|
||||
if (this.register) {
|
||||
this.emit(
|
||||
R3.Event.COMPONENT_REGISTER,
|
||||
{
|
||||
component : this
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (this.dependencies.length === 0) {
|
||||
|
||||
|
|
|
@ -10,17 +10,7 @@ R3.API.Box3 = function(
|
|||
min,
|
||||
max
|
||||
) {
|
||||
if (R3.Utils.UndefinedOrNull(apiComponent)) {
|
||||
apiComponent = {};
|
||||
}
|
||||
this.apiComponent = apiComponent;
|
||||
|
||||
R3.API.Component.call(
|
||||
this,
|
||||
this.apiComponent.parent,
|
||||
this.apiComponent.id,
|
||||
this.apiComponent.name
|
||||
);
|
||||
__API_COMPONENT_MACRO__;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(min)) {
|
||||
min = new R3.API.Vector3();
|
||||
|
|
|
@ -21,17 +21,7 @@ R3.API.Canvas = function(
|
|||
textBaseline
|
||||
) {
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(apiComponent)) {
|
||||
apiComponent = {};
|
||||
}
|
||||
this.apiComponent = apiComponent;
|
||||
|
||||
R3.API.Component.call(
|
||||
this,
|
||||
this.apiComponent.parent,
|
||||
this.apiComponent.id,
|
||||
this.apiComponent.name
|
||||
);
|
||||
__API_COMPONENT_MACRO__;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(autoUpdateSize)) {
|
||||
autoUpdateSize = true;
|
||||
|
|
|
@ -16,7 +16,7 @@ R3.API.Controls = function(
|
|||
* Try to attach the controls to the parent canvas
|
||||
* @type {null}
|
||||
*/
|
||||
canvas = this.getParent('canvas');
|
||||
canvas = this.getFirstParent(R3.API.Canvas);
|
||||
}
|
||||
this.canvas = canvas;
|
||||
};
|
||||
|
|
|
@ -18,15 +18,8 @@ R3.API.Controls.D3 = function(
|
|||
);
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(camera)) {
|
||||
/**
|
||||
* Get the cameraIndexEdit of the scene which is responsible for these controls
|
||||
*/
|
||||
var cameraIndex = this.getParent('cameraIndexEdit');
|
||||
|
||||
/**
|
||||
* Now get the camera with this index from our project cameras
|
||||
*/
|
||||
camera = this.getParent('cameras', cameraIndex);
|
||||
var project = this.getFirstParent(R3.API.Project);
|
||||
camera = project.cameras[R3.API.Project.CAMERA_INDEX_EDIT];
|
||||
}
|
||||
this.camera = camera;
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* @param path - Relative to API URL
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.API.Font = function(
|
||||
R3.API.Font = function(
|
||||
apiComponent,
|
||||
path
|
||||
) {
|
||||
|
@ -18,5 +18,5 @@ R3.D3.API.Font = function(
|
|||
|
||||
};
|
||||
|
||||
R3.D3.API.Font.prototype = Object.create(R3.API.Component.prototype);
|
||||
R3.D3.API.Font.prototype.constructor = R3.D3.API.Font;
|
||||
R3.API.Font.prototype = Object.create(R3.API.Component.prototype);
|
||||
R3.API.Font.prototype.constructor = R3.API.Font;
|
|
@ -1,11 +1,9 @@
|
|||
/**
|
||||
* R3.Box3
|
||||
* @param parent
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.Box3 = function(
|
||||
parent,
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
|
@ -30,10 +28,7 @@ R3.Box3 = function(
|
|||
|
||||
this.componentRuntime = R3.Component.GetComponentRuntime(this.parent);
|
||||
|
||||
R3.Component.call(
|
||||
this,
|
||||
parent
|
||||
);
|
||||
R3.Component.call(this);
|
||||
};
|
||||
|
||||
R3.Box3.prototype = Object.create(R3.Component.prototype);
|
||||
|
|
|
@ -32,7 +32,6 @@ R3.Canvas = function(
|
|||
|
||||
R3.Component.call(
|
||||
this,
|
||||
parent,
|
||||
{
|
||||
'texts' : [R3.D3.Text]
|
||||
}
|
||||
|
|
|
@ -26,11 +26,6 @@ R3.Curve = function(
|
|||
apiComponent.arcLenghDivisions
|
||||
);
|
||||
|
||||
R3.Component.call(
|
||||
this,
|
||||
parent
|
||||
);
|
||||
|
||||
} else {
|
||||
|
||||
/**
|
||||
|
@ -38,16 +33,14 @@ R3.Curve = function(
|
|||
* Add any more linking information to the linkedObjects object here
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
R3.Component.call(
|
||||
this,
|
||||
parent,
|
||||
linkedObjects
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
R3.Curve.prototype = Object.create(R3.Component.prototype);
|
||||
|
|
|
@ -22,25 +22,9 @@ R3.D3.API.Face.Graphics = function(
|
|||
apiFace.v1index,
|
||||
apiFace.v2index,
|
||||
apiFace.vertexNormals,
|
||||
apiFace.normal,
|
||||
apiFace.selected
|
||||
apiFace.normal
|
||||
);
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(v0index)) {
|
||||
v0index = -1;
|
||||
}
|
||||
this.v0index = v0index;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(v1index)) {
|
||||
v1index = -1;
|
||||
}
|
||||
this.v1index = v1index;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(v2index)) {
|
||||
v2index = -1;
|
||||
}
|
||||
this.v2index = v2index;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(materialIndex)) {
|
||||
materialIndex = -1;
|
||||
}
|
||||
|
@ -65,46 +49,26 @@ R3.D3.API.Face.Graphics = function(
|
|||
}
|
||||
this.vertexColors = vertexColors;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(vertexNormals)) {
|
||||
vertexNormals = [];
|
||||
}
|
||||
this.vertexNormals = vertexNormals;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(normal)) {
|
||||
normal = null;
|
||||
}
|
||||
this.normal = normal;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(selected)) {
|
||||
selected = false;
|
||||
}
|
||||
this.selected = selected;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* We don't inherit from component - it makes the entitymanager too heavy - all faces end up in the register etc..
|
||||
*/
|
||||
|
||||
R3.D3.API.Face.Graphics.prototype = Object.create(R3.API.Component.prototype);
|
||||
R3.D3.API.Face.Graphics.prototype = Object.create(R3.D3.API.Face.prototype);
|
||||
R3.D3.API.Face.Graphics.prototype.constructor = R3.D3.API.Face.Graphics;
|
||||
|
||||
/**
|
||||
* Clone a Face
|
||||
* @returns {R3.D3.API.Face}
|
||||
* Clone
|
||||
* @returns {R3.D3.API.Face.Graphics}
|
||||
*/
|
||||
R3.D3.API.Face.Graphics.prototype.clone = function(){
|
||||
return new R3.D3.API.Face(
|
||||
null,
|
||||
this.v0index,
|
||||
this.v1index,
|
||||
this.v2index,
|
||||
|
||||
var apiFace = R3.D3.API.Face.prototype.clone.call(
|
||||
this
|
||||
);
|
||||
|
||||
return new R3.D3.API.Face.Graphics(
|
||||
apiFace,
|
||||
this.materialIndex,
|
||||
this.uvs,
|
||||
this.color,
|
||||
this.vertexColors,
|
||||
this.vertexNormals,
|
||||
this.normal,
|
||||
this.selected
|
||||
this.vertexColors
|
||||
);
|
||||
};
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
* @param v2index
|
||||
* @param vertexNormals
|
||||
* @param normal
|
||||
* @param selected
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.API.Face = function(
|
||||
|
@ -15,10 +14,32 @@ R3.D3.API.Face = function(
|
|||
v1index,
|
||||
v2index,
|
||||
vertexNormals,
|
||||
normal,
|
||||
selected
|
||||
normal
|
||||
) {
|
||||
|
||||
/**
|
||||
* By default, we want to avoid registering faces as components
|
||||
*/
|
||||
if (R3.Utils.UndefinedOrNull(apiComponent)) {
|
||||
apiComponent = {};
|
||||
}
|
||||
|
||||
apiComponent.register = false;
|
||||
|
||||
/**
|
||||
* Check whether we need to register the faces
|
||||
* @type {boolean}
|
||||
*/
|
||||
R3.Event.Emit(
|
||||
R3.Event.GET_REGISTER_FACES,
|
||||
null,
|
||||
function(register) {
|
||||
if (register) {
|
||||
apiComponent.register = true;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
__API_COMPONENT_MACRO__;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(v0index)) {
|
||||
|
@ -46,17 +67,8 @@ R3.D3.API.Face = function(
|
|||
}
|
||||
this.normal = normal;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(selected)) {
|
||||
selected = false;
|
||||
}
|
||||
this.selected = selected;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* We don't inherit from component - it makes the entitymanager too heavy - all faces end up in the register etc..
|
||||
*/
|
||||
|
||||
R3.D3.API.Face.prototype = Object.create(R3.API.Component.prototype);
|
||||
R3.D3.API.Face.prototype.constructor = R3.D3.API.Face;
|
||||
|
||||
|
@ -71,8 +83,7 @@ R3.D3.API.Face.prototype.clone = function(){
|
|||
this.v1index,
|
||||
this.v2index,
|
||||
this.vertexNormals,
|
||||
this.normal,
|
||||
this.selected
|
||||
this.normal
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* R3.D3.API.Fog.Exp
|
||||
* @param apiFog
|
||||
* @param density
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.API.Fog.Exp = function(
|
||||
apiFog,
|
||||
density
|
||||
) {
|
||||
|
||||
__API_COMPONENT_MACRO__;
|
||||
|
||||
R3.D3.API.Fog.call(
|
||||
this,
|
||||
apiFog,
|
||||
apiFog.color
|
||||
);
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(density)) {
|
||||
density = 0.00025;
|
||||
}
|
||||
this.density = density;
|
||||
|
||||
};
|
||||
|
||||
R3.D3.API.Fog.Exp.prototype = Object.create(R3.D3.API.Fog.prototype);
|
||||
R3.D3.API.Fog.Exp.prototype.constructor = R3.D3.API.Fog.Exp;
|
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* R3.D3.API.Fog.Normal
|
||||
* @param apiFog
|
||||
* @param near
|
||||
* @param far
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.API.Fog.Normal = function(
|
||||
apiFog,
|
||||
near,
|
||||
far,
|
||||
) {
|
||||
|
||||
__API_COMPONENT_MACRO__;
|
||||
|
||||
R3.D3.API.Fog.call(
|
||||
this,
|
||||
apiFog,
|
||||
apiFog.color
|
||||
);
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(near)) {
|
||||
near = 1;
|
||||
}
|
||||
this.near = near;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(far)) {
|
||||
far = 1000;
|
||||
}
|
||||
this.far = far;
|
||||
|
||||
};
|
||||
|
||||
R3.D3.API.Fog.Normal.prototype = Object.create(R3.D3.API.Fog.prototype);
|
||||
R3.D3.API.Fog.Normal.prototype.constructor = R3.D3.API.Fog.Normal;
|
|
@ -1,49 +1,21 @@
|
|||
/**
|
||||
* R3.D3.API.Fog
|
||||
* @param apiComponent
|
||||
* @param exponential
|
||||
* @param color
|
||||
* @param near
|
||||
* @param far
|
||||
* @param density
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.API.Fog = function(
|
||||
apiComponent,
|
||||
exponential,
|
||||
color,
|
||||
near,
|
||||
far,
|
||||
density
|
||||
color
|
||||
) {
|
||||
|
||||
__API_COMPONENT_MACRO__;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(exponential)) {
|
||||
exponential = false;
|
||||
}
|
||||
this.exponential = exponential;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(color)) {
|
||||
color = new R3.API.Color(this, 1, 1, 1, 1)
|
||||
}
|
||||
this.color = color;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(near)) {
|
||||
near = 1;
|
||||
}
|
||||
this.near = near;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(far)) {
|
||||
far = 1000;
|
||||
}
|
||||
this.far = far;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(density)) {
|
||||
density = 0.00025;
|
||||
}
|
||||
this.density = density;
|
||||
|
||||
};
|
||||
|
||||
R3.D3.API.Fog.prototype = Object.create(R3.API.Component.prototype);
|
||||
|
|
|
@ -18,22 +18,41 @@ R3.D3.API.Geometry = function(
|
|||
__API_COMPONENT_MACRO__;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(boundingBox)) {
|
||||
boundingBox = new R3.API.Box3();
|
||||
boundingBox = new R3.API.Box3(
|
||||
{
|
||||
parent : this
|
||||
}
|
||||
);
|
||||
}
|
||||
this.boundingBox = boundingBox;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(boundingSphere)) {
|
||||
boundingSphere = new R3.API.Sphere();
|
||||
boundingSphere = new R3.API.Sphere(
|
||||
{
|
||||
parent : this
|
||||
}
|
||||
);
|
||||
}
|
||||
this.boundingSphere = boundingSphere;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(faces)) {
|
||||
faces = [];
|
||||
faces = [
|
||||
new R3.D3.API.Face(
|
||||
{
|
||||
parent : this
|
||||
},
|
||||
0,
|
||||
1,
|
||||
2
|
||||
)
|
||||
];
|
||||
}
|
||||
this.faces = faces;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(vertices)) {
|
||||
vertices = [];
|
||||
vertices = [
|
||||
new R3.API.Vector3()
|
||||
];
|
||||
}
|
||||
this.vertices = vertices;
|
||||
};
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
/**
|
||||
* R3.D3.API.Material
|
||||
* @param id
|
||||
* @param name
|
||||
* @param materialType
|
||||
* @param parent
|
||||
* @param apiComponent
|
||||
* @param parentMeshes
|
||||
* @param alphaTest
|
||||
* @param blendDst
|
||||
|
|
|
@ -4,12 +4,10 @@
|
|||
* - This class should not be instantiated - it is inherited by some objects to define common properties for 3D objects,
|
||||
* for example position, rotation, scale etc
|
||||
*
|
||||
* @param parent
|
||||
* @param linkedObjects
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Object = function(
|
||||
parent,
|
||||
linkedObjects
|
||||
) {
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/**
|
||||
* R3.D3.Animation
|
||||
* @param parent
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Animation = function(
|
||||
parent,
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/**
|
||||
* R3.D3.Audio
|
||||
* @param parent
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Audio = function(
|
||||
parent,
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/**
|
||||
* R3.D3.BoneWeight
|
||||
* @param parent
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.BoneWeight = function(
|
||||
parent,
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
|
@ -19,8 +17,7 @@ R3.D3.BoneWeight = function(
|
|||
);
|
||||
|
||||
R3.Component.call(
|
||||
this,
|
||||
parent
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/**
|
||||
* R3.D3.Bone
|
||||
* @param parent
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Bone = function(
|
||||
parent,
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
|
@ -19,8 +17,7 @@ R3.D3.Bone = function(
|
|||
);
|
||||
|
||||
R3.D3.Object.call(
|
||||
this,
|
||||
parent
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/**
|
||||
* R3.D3.Broadphase
|
||||
* @param parent
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Broadphase = function(
|
||||
parent,
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
|
@ -18,8 +16,7 @@ R3.D3.Broadphase = function(
|
|||
);
|
||||
|
||||
R3.Component.call(
|
||||
this,
|
||||
parent
|
||||
this
|
||||
);
|
||||
|
||||
};
|
||||
|
|
|
@ -3,18 +3,15 @@
|
|||
*
|
||||
* - This class cannot be instantiated - simply pass it all through to R3.D3.Object
|
||||
*
|
||||
* @param parent
|
||||
* @param linkedObjects
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Camera = function(
|
||||
parent,
|
||||
linkedObjects
|
||||
) {
|
||||
|
||||
R3.D3.Object.call(
|
||||
this,
|
||||
parent,
|
||||
linkedObjects
|
||||
);
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/**
|
||||
* R3.D3.Camera.Cube
|
||||
* @param parent
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Camera.Cube = function(
|
||||
parent,
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
|
@ -30,7 +28,6 @@ R3.D3.Camera.Cube = function(
|
|||
|
||||
R3.D3.Camera.call(
|
||||
this,
|
||||
parent,
|
||||
linkedObjects
|
||||
);
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/**
|
||||
* R3.D3.Camera.Orthographic.FixedAspect
|
||||
* @param parent
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Camera.Orthographic.FixedAspect = function(
|
||||
parent,
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
|
@ -20,7 +18,6 @@ R3.D3.Camera.Orthographic.FixedAspect = function(
|
|||
|
||||
R3.D3.Camera.Orthographic.call(
|
||||
this,
|
||||
parent,
|
||||
linkedObjects
|
||||
);
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/**
|
||||
* R3.D3.Camera.Orthographic.ScaledAspect
|
||||
* @param parent
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Camera.Orthographic.ScaledAspect = function(
|
||||
parent,
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
|
@ -24,7 +22,6 @@ R3.D3.Camera.Orthographic.ScaledAspect = function(
|
|||
|
||||
R3.D3.Camera.Orthographic.call(
|
||||
this,
|
||||
parent,
|
||||
linkedObjects
|
||||
);
|
||||
|
||||
|
|
|
@ -3,18 +3,15 @@
|
|||
*
|
||||
* - This is an abstract class - should not be instantiated directly
|
||||
*
|
||||
* @param parent
|
||||
* @param linkedObjects
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Camera.Orthographic = function(
|
||||
parent,
|
||||
linkedObjects
|
||||
) {
|
||||
|
||||
R3.D3.Camera.call(
|
||||
this,
|
||||
parent,
|
||||
linkedObjects
|
||||
);
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/**
|
||||
* R3.D3.Camera.Perspective.Stereo
|
||||
* @param parent
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Camera.Perspective.Stereo = function(
|
||||
parent,
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
|
@ -21,7 +19,6 @@ R3.D3.Camera.Perspective.Stereo = function(
|
|||
|
||||
R3.D3.Camera.call(
|
||||
this,
|
||||
parent,
|
||||
linkedObjects
|
||||
);
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/**
|
||||
* R3.D3.Camera.Perspective
|
||||
* @param parent
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Camera.Perspective = function(
|
||||
parent,
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
|
@ -27,7 +25,6 @@ R3.D3.Camera.Perspective = function(
|
|||
|
||||
R3.D3.Camera.call(
|
||||
this,
|
||||
parent,
|
||||
linkedObjects
|
||||
);
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/**
|
||||
* R3.D3.Composer.RenderTarget
|
||||
* @param parent
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Composer.RenderTarget = function(
|
||||
parent,
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
|
@ -27,7 +25,6 @@ R3.D3.Composer.RenderTarget = function(
|
|||
|
||||
R3.D3.Composer.call(
|
||||
this,
|
||||
parent,
|
||||
linkedObjects
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/**
|
||||
* R3.D3.Composer.Renderer
|
||||
* @param parent
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Composer.Renderer = function(
|
||||
parent,
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
|
@ -27,7 +25,6 @@ R3.D3.Composer.Renderer = function(
|
|||
|
||||
R3.D3.Composer.call(
|
||||
this,
|
||||
parent,
|
||||
linkedObjects
|
||||
);
|
||||
};
|
||||
|
|
|
@ -3,12 +3,10 @@
|
|||
*
|
||||
* - This is an abstract class, don't instatiate it directly
|
||||
*
|
||||
* @param parent
|
||||
* @param linkedObjects
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Composer = function(
|
||||
parent,
|
||||
linkedObjects
|
||||
) {
|
||||
|
||||
|
@ -34,7 +32,6 @@ R3.D3.Composer = function(
|
|||
|
||||
R3.Component.call(
|
||||
this,
|
||||
parent,
|
||||
linkedObjects
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/**
|
||||
* R3.D3.Effect
|
||||
* @param parent
|
||||
* @param linkedObjects
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Effect = function(
|
||||
parent,
|
||||
linkedObjects
|
||||
) {
|
||||
|
||||
|
@ -34,7 +32,6 @@ R3.D3.Effect = function(
|
|||
|
||||
R3.Component.call(
|
||||
this,
|
||||
parent,
|
||||
linkedObjects
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/**
|
||||
* R3.D3.Effect.Anaglyph
|
||||
* @param parent
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Effect.Anaglyph = function(
|
||||
parent,
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
|
@ -17,8 +15,7 @@ R3.D3.Effect.Anaglyph = function(
|
|||
);
|
||||
|
||||
R3.D3.Effect.call(
|
||||
this,
|
||||
parent
|
||||
this
|
||||
);
|
||||
|
||||
};
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/**
|
||||
* R3.D3.Effect.Parallax
|
||||
* @param parent
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Effect.Parallax = function(
|
||||
parent,
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
|
@ -17,8 +15,7 @@ R3.D3.Effect.Parallax = function(
|
|||
);
|
||||
|
||||
R3.D3.Effect.call(
|
||||
this,
|
||||
parent
|
||||
this
|
||||
);
|
||||
|
||||
};
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/**
|
||||
* R3.D3.Effect.Stereo
|
||||
* @param parent
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Effect.Stereo = function(
|
||||
parent,
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
|
@ -17,8 +15,7 @@ R3.D3.Effect.Stereo = function(
|
|||
);
|
||||
|
||||
R3.D3.Effect.call(
|
||||
this,
|
||||
parent
|
||||
this
|
||||
);
|
||||
|
||||
};
|
||||
|
|
|
@ -1,91 +1,21 @@
|
|||
/**
|
||||
* R3.D3.Face
|
||||
* @param parent
|
||||
* R3.D3.Face.Graphics
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Face.Graphics = function(
|
||||
parent,
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
__RUNTIME_COMPONENT_MACRO__;
|
||||
|
||||
R3.D3.Face.call(
|
||||
this,
|
||||
parent,
|
||||
apiComponent,
|
||||
linkedObjects
|
||||
);
|
||||
|
||||
R3.D3.API.Face.call(
|
||||
R3.D3.API.Face.Graphics.call(
|
||||
this,
|
||||
apiComponent,
|
||||
apiComponent.v0index,
|
||||
apiComponent.v1index,
|
||||
apiComponent.v2index,
|
||||
apiComponent.materialIndex,
|
||||
apiComponent.uvs,
|
||||
apiComponent.color,
|
||||
apiComponent.vertexColors,
|
||||
apiComponent.vertexNormals,
|
||||
apiComponent.normal,
|
||||
apiComponent.selected
|
||||
);
|
||||
|
||||
this.componentRuntime = R3.Component.GetComponentRuntime(this.parent);
|
||||
|
||||
switch (this.componentRuntime) {
|
||||
case R3.Component.GRAPHICS_RUNTIME :
|
||||
break;
|
||||
case R3.Component.PHYSICS_RUNTIME :
|
||||
break;
|
||||
}
|
||||
|
||||
R3.Component.call(
|
||||
this,
|
||||
parent
|
||||
);
|
||||
|
||||
if (this.implementation instanceof R3.Runtime.Graphics) {
|
||||
/**
|
||||
* physics faces have no color... a little sad right?
|
||||
*/
|
||||
this.color = new R3.Color(
|
||||
this.implementation,
|
||||
this.color,
|
||||
this
|
||||
);
|
||||
|
||||
this.vertexColors = this.vertexColors.map(function(vertexColor){
|
||||
|
||||
return new R3.Color(
|
||||
this.implementation,
|
||||
vertexColor,
|
||||
this
|
||||
);
|
||||
/*
|
||||
if (vertexColor instanceof R3.Color) {
|
||||
return vertexColor;
|
||||
}
|
||||
|
||||
if (vertexColor instanceof R3.API.Color) {
|
||||
|
||||
}
|
||||
|
||||
console.warn('unknown vertex color type', vertexColor);*/
|
||||
}.bind(this));
|
||||
|
||||
}
|
||||
|
||||
this.vertexNormals = this.vertexNormals.map(
|
||||
function(vertexNormal) {
|
||||
return new R3.Vector3(
|
||||
this.implementation,
|
||||
vertexNormal,
|
||||
this
|
||||
);
|
||||
}.bind(this)
|
||||
apiComponent.vertexColors
|
||||
);
|
||||
|
||||
this.uvs = this.uvs.reduce(
|
||||
|
@ -93,13 +23,13 @@ R3.D3.Face.Graphics = function(
|
|||
function(result, uvs, uvSet) {
|
||||
|
||||
result[uvSet] = uvs.reduce(
|
||||
|
||||
function(uvResult, uv) {
|
||||
|
||||
uvResult.push(
|
||||
new R3.Vector2(
|
||||
this.implementation,
|
||||
uv,
|
||||
this
|
||||
this,
|
||||
uv
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -115,10 +45,31 @@ R3.D3.Face.Graphics = function(
|
|||
[]
|
||||
);
|
||||
|
||||
this.normal = new R3.Vector3(
|
||||
this.implementation,
|
||||
this.normal,
|
||||
this
|
||||
this.color = new R3.Color(
|
||||
this,
|
||||
this.color
|
||||
);
|
||||
|
||||
this.vertexColors = this.vertexColors.reduce(
|
||||
function(result, vertexColor) {
|
||||
|
||||
result.push(
|
||||
new R3.Color(
|
||||
this,
|
||||
vertexColor
|
||||
)
|
||||
);
|
||||
|
||||
return result;
|
||||
|
||||
}.bind(this),
|
||||
[]
|
||||
);
|
||||
|
||||
R3.D3.Face.call(
|
||||
this,
|
||||
apiComponent,
|
||||
{}
|
||||
);
|
||||
|
||||
};
|
||||
|
@ -126,107 +77,68 @@ R3.D3.Face.Graphics = function(
|
|||
R3.D3.Face.Graphics.prototype = Object.create(R3.D3.Face.prototype);
|
||||
R3.D3.Face.Graphics.prototype.constructor = R3.D3.Face.Graphics;
|
||||
|
||||
/**
|
||||
* We don't follow the standard procedure for Faces - We don't want them in the EntityManager registry - so
|
||||
* they don't call component createinstance
|
||||
* @param parentGeometry
|
||||
*/
|
||||
R3.D3.Face.Graphics.prototype.createInstance = function(parentGeometry) {
|
||||
R3.D3.Face.Graphics.prototype.createInstance = function() {
|
||||
|
||||
this.instance = new THREE.Face3(
|
||||
this.instance = this.graphics.Face(
|
||||
this.v0index,
|
||||
this.v1index,
|
||||
this.v2index
|
||||
this.v2index,
|
||||
this.normal,
|
||||
this.color,
|
||||
this.materialIndex,
|
||||
this.vertexColors
|
||||
);
|
||||
|
||||
if (this.normal) {
|
||||
this.instance.normal = new THREE.Vector3(
|
||||
this.normal.x,
|
||||
this.normal.y,
|
||||
this.normal.z
|
||||
);
|
||||
}
|
||||
|
||||
if (this.color) {
|
||||
this.instance.color = new THREE.Color(
|
||||
this.color.r,
|
||||
this.color.g,
|
||||
this.color.b
|
||||
)
|
||||
}
|
||||
|
||||
this.instance.materialIndex = this.materialIndex;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(parentGeometry)) {
|
||||
console.warn('please pass a parentmesh to face createInstance()');
|
||||
}
|
||||
this.parentGeometry = parentGeometry;
|
||||
R3.Component.prototype.createInstance.call(this);
|
||||
};
|
||||
|
||||
R3.D3.Face.Graphics.prototype.updateInstance = function(property, uvSet, uvIndex) {
|
||||
R3.D3.Face.Graphics.prototype.updateInstance = function(property) {
|
||||
|
||||
if (property === 'materialIndex') {
|
||||
this.instance.materialIndex = this.materialIndex;
|
||||
this.parentGeometry.instance.groupsNeedUpdate = true;
|
||||
this.parent.instance.groupsNeedUpdate = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (property === 'uvs') {
|
||||
|
||||
this.uvs[uvSet][uvIndex].instance.x = this.uvs[uvSet][uvIndex].x;
|
||||
this.uvs[uvSet][uvIndex].instance.y = this.uvs[uvSet][uvIndex].y;
|
||||
this.parentGeometry.instance.uvsNeedUpdate = true;
|
||||
this.parent.instance.uvsNeedUpdate = true;
|
||||
return;
|
||||
}
|
||||
|
||||
console.warn('todo: update face property: ' + property);
|
||||
};
|
||||
|
||||
R3.D3.Face.prototype.toApiObject = function() {
|
||||
|
||||
return new R3.D3.API.Face(
|
||||
this.id,
|
||||
this.name,
|
||||
this.v0index,
|
||||
this.v1index,
|
||||
this.v2index,
|
||||
this.materialIndex,
|
||||
this.uvs.reduce(
|
||||
function(result, uvArray, index) {
|
||||
|
||||
result[index] = uvArray.reduce(
|
||||
function(uvResult, uv) {
|
||||
|
||||
if (uv instanceof R3.Vector2) {
|
||||
uvResult.push(uv.toApiObject());
|
||||
} else {
|
||||
console.warn('unknown uv type - cannot commit to API');
|
||||
if (property === 'color') {
|
||||
this.instance.color.r = this.color.r;
|
||||
this.instance.color.g = this.color.g;
|
||||
this.instance.color.b = this.color.b;
|
||||
return;
|
||||
}
|
||||
|
||||
return uvResult;
|
||||
}.bind(this),
|
||||
[]
|
||||
if (property === 'vertexColors') {
|
||||
this.instance.vertexColors = this.vertexColors.reduce(
|
||||
function(result, vertexColor) {
|
||||
result.push(
|
||||
this.graphics.Color(
|
||||
vertexColor.r,
|
||||
vertexColor.g,
|
||||
vertexColor.b
|
||||
)
|
||||
);
|
||||
|
||||
return result;
|
||||
|
||||
}.bind(this),
|
||||
[]
|
||||
),
|
||||
this.color.toApiObject(),
|
||||
this.vertexColors.map(function(vertexColor){
|
||||
return vertexColor.toApiObject();
|
||||
}),
|
||||
this.vertexNormals.map(function(vertexNormal){
|
||||
return vertexNormal.toApiObject();
|
||||
}),
|
||||
this.normal.toApiObject(),
|
||||
this.selected
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
R3.D3.Face.prototype.updateInstance.call(this, property);
|
||||
};
|
||||
|
||||
|
||||
R3.D3.Face.prototype.createHelper = function(mesh) {
|
||||
R3.D3.Face.Graphics.prototype.createHelper = function() {
|
||||
|
||||
console.warn('todo: createHelper needs work');
|
||||
return;
|
||||
|
||||
this.backupProperties = {
|
||||
color : {
|
||||
|
@ -242,6 +154,7 @@ R3.D3.Face.prototype.createHelper = function(mesh) {
|
|||
b: mesh.materials[this.materialIndex].emissive.b
|
||||
}
|
||||
},
|
||||
|
||||
vertexColors : mesh.materials[this.materialIndex].vertexColors
|
||||
};
|
||||
|
||||
|
@ -251,16 +164,6 @@ R3.D3.Face.prototype.createHelper = function(mesh) {
|
|||
new THREE.Color(0,0,1)
|
||||
];
|
||||
|
||||
// this.instance.color.r = 1;
|
||||
// this.instance.color.g = 0;
|
||||
// this.instance.color.b = 0;
|
||||
|
||||
//
|
||||
// mesh.materials[this.materialIndex].emissive.r = 0.5;
|
||||
// mesh.materials[this.materialIndex].emissive.g = 0.5;
|
||||
// mesh.materials[this.materialIndex].emissive.b = 0.5;
|
||||
// mesh.materials[this.materialIndex].updateInstance('emissive');
|
||||
|
||||
mesh.materials[this.materialIndex].vertexColors = R3.D3.API.Material.TYPE_VERTEX_COLORS;
|
||||
mesh.materials[this.materialIndex].updateInstance('vertexColors');
|
||||
|
||||
|
@ -268,7 +171,10 @@ R3.D3.Face.prototype.createHelper = function(mesh) {
|
|||
|
||||
};
|
||||
|
||||
R3.D3.Face.prototype.removeHelper = function(mesh) {
|
||||
R3.D3.Face.Graphics.prototype.removeHelper = function() {
|
||||
|
||||
console.warn('todo: removeHelper needs work');
|
||||
return;
|
||||
|
||||
this.instance.color.r = this.backupProperties.color.r;
|
||||
this.instance.color.g = this.backupProperties.color.g;
|
||||
|
@ -276,11 +182,6 @@ R3.D3.Face.prototype.removeHelper = function(mesh) {
|
|||
|
||||
mesh.instance.geometry.colorsNeedUpdate = true;
|
||||
|
||||
// mesh.materials[this.materialIndex].emissive.r = this.backupProperties.material.emissive.r;
|
||||
// mesh.materials[this.materialIndex].emissive.g = this.backupProperties.material.emissive.g;
|
||||
// mesh.materials[this.materialIndex].emissive.b = this.backupProperties.material.emissive.b;
|
||||
// mesh.materials[this.materialIndex].updateInstance('emissive');
|
||||
|
||||
mesh.materials[this.materialIndex].vertexColors = this.backupProperties.vertexColors;
|
||||
mesh.materials[this.materialIndex].updateInstance('vertexColors');
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/**
|
||||
* R3.D3.Face
|
||||
* @param parent
|
||||
* @param apiComponent
|
||||
* @param linkedObjects
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Face = function(
|
||||
parent,
|
||||
apiComponent,
|
||||
linkedObjects
|
||||
) {
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(linkedObjects)) {
|
||||
|
||||
__RUNTIME_COMPONENT_MACRO__;
|
||||
|
||||
R3.D3.API.Face.call(
|
||||
|
@ -20,10 +20,11 @@ R3.D3.Face = function(
|
|||
apiComponent.v1index,
|
||||
apiComponent.v2index,
|
||||
apiComponent.vertexNormals,
|
||||
apiComponent.normal,
|
||||
apiComponent.selected
|
||||
apiComponent.normal
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
this.componentRuntime = R3.Component.GetComponentRuntime(this.parent);
|
||||
|
||||
this.vertexNormals = this.vertexNormals.reduce(
|
||||
|
@ -31,7 +32,7 @@ R3.D3.Face = function(
|
|||
|
||||
result.push(
|
||||
new R3.Vector3(
|
||||
parent,
|
||||
this,
|
||||
vertexNormal
|
||||
)
|
||||
);
|
||||
|
@ -42,13 +43,12 @@ R3.D3.Face = function(
|
|||
);
|
||||
|
||||
this.normal = new R3.Vector3(
|
||||
parent,
|
||||
this,
|
||||
this.normal
|
||||
);
|
||||
|
||||
R3.Component.call(
|
||||
this,
|
||||
parent,
|
||||
linkedObjects
|
||||
);
|
||||
|
||||
|
@ -62,165 +62,90 @@ R3.D3.Face.prototype.constructor = R3.D3.Face;
|
|||
* they don't call component createinstance
|
||||
* @param parentGeometry
|
||||
*/
|
||||
R3.D3.Face.prototype.createInstance = function(parentGeometry) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
R3.D3.Face.prototype.createInstance = function() {
|
||||
|
||||
switch (this.componentRuntime) {
|
||||
case R3.Component.GRAPHICS_RUNTIME :
|
||||
break;
|
||||
case R3.Component.PHYSICS_RUNTIME :
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
this.instance = new THREE.Face3(
|
||||
this.v0index,
|
||||
this.v1index,
|
||||
this.v2index
|
||||
);
|
||||
|
||||
if (this.normal) {
|
||||
this.instance.normal = new THREE.Vector3(
|
||||
this.normal.x,
|
||||
this.normal.y,
|
||||
this.normal.z
|
||||
);
|
||||
}
|
||||
|
||||
if (this.color) {
|
||||
this.instance.color = new THREE.Color(
|
||||
this.color.r,
|
||||
this.color.g,
|
||||
this.color.b
|
||||
)
|
||||
}
|
||||
|
||||
this.instance.materialIndex = this.materialIndex;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(parentGeometry)) {
|
||||
console.warn('please pass a parentmesh to face createInstance()');
|
||||
}
|
||||
this.parentGeometry = parentGeometry;
|
||||
};
|
||||
|
||||
R3.D3.Face.prototype.updateInstance = function(property, uvSet, uvIndex) {
|
||||
|
||||
if (property === 'materialIndex') {
|
||||
this.instance.materialIndex = this.materialIndex;
|
||||
this.parentGeometry.instance.groupsNeedUpdate = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (property === 'uvs') {
|
||||
|
||||
this.uvs[uvSet][uvIndex].instance.x = this.uvs[uvSet][uvIndex].x;
|
||||
this.uvs[uvSet][uvIndex].instance.y = this.uvs[uvSet][uvIndex].y;
|
||||
this.parentGeometry.instance.uvsNeedUpdate = true;
|
||||
return;
|
||||
}
|
||||
|
||||
console.warn('todo: update face property: ' + property);
|
||||
};
|
||||
|
||||
R3.D3.Face.prototype.toApiObject = function() {
|
||||
|
||||
return new R3.D3.API.Face(
|
||||
this.id,
|
||||
this.name,
|
||||
this.instance = this.graphics.Face(
|
||||
this.v0index,
|
||||
this.v1index,
|
||||
this.v2index,
|
||||
this.materialIndex,
|
||||
this.uvs.reduce(
|
||||
function(result, uvArray, index) {
|
||||
this.normal,
|
||||
);
|
||||
|
||||
result[index] = uvArray.reduce(
|
||||
function(uvResult, uv) {
|
||||
break;
|
||||
|
||||
if (uv instanceof R3.Vector2) {
|
||||
uvResult.push(uv.toApiObject());
|
||||
} else {
|
||||
console.warn('unknown uv type - cannot commit to API');
|
||||
case R3.Component.PHYSICS_RUNTIME :
|
||||
|
||||
this.instance = this.physics.Face(
|
||||
this.v0index,
|
||||
this.v1index,
|
||||
this.v2index,
|
||||
this.normal,
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return uvResult;
|
||||
}.bind(this),
|
||||
[]
|
||||
R3.Component.prototype.createInstance.call(this);
|
||||
|
||||
};
|
||||
|
||||
R3.D3.Face.prototype.updateInstance = function(property) {
|
||||
|
||||
if (property === 'v0index') {
|
||||
this.instance.a = this.v0index;
|
||||
return;
|
||||
}
|
||||
|
||||
if (property === 'v1index') {
|
||||
this.instance.b = this.v1index;
|
||||
return;
|
||||
}
|
||||
|
||||
if (property === 'v2index') {
|
||||
this.instance.c = this.v2index;
|
||||
return;
|
||||
}
|
||||
|
||||
if (property === 'vertexNormals') {
|
||||
|
||||
this.instance.vertexNormals = this.vertexNormals.reduce(
|
||||
function(result, vertexNormal) {
|
||||
|
||||
result.push(
|
||||
new R3.Vector3(
|
||||
this,
|
||||
vertexNormal
|
||||
)
|
||||
);
|
||||
|
||||
return result;
|
||||
|
||||
}.bind(this),
|
||||
[]
|
||||
),
|
||||
this.color.toApiObject(),
|
||||
this.vertexColors.map(function(vertexColor){
|
||||
return vertexColor.toApiObject();
|
||||
}),
|
||||
this.vertexNormals.map(function(vertexNormal){
|
||||
return vertexNormal.toApiObject();
|
||||
}),
|
||||
this.normal.toApiObject(),
|
||||
this.selected
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
R3.D3.Face.prototype.createHelper = function(mesh) {
|
||||
|
||||
this.backupProperties = {
|
||||
color : {
|
||||
r: this.color.r,
|
||||
g: this.color.g,
|
||||
b: this.color.b
|
||||
},
|
||||
|
||||
material : {
|
||||
emissive : {
|
||||
r: mesh.materials[this.materialIndex].emissive.r,
|
||||
g: mesh.materials[this.materialIndex].emissive.g,
|
||||
b: mesh.materials[this.materialIndex].emissive.b
|
||||
return;
|
||||
}
|
||||
},
|
||||
vertexColors : mesh.materials[this.materialIndex].vertexColors
|
||||
};
|
||||
|
||||
this.instance.vertexColors = [
|
||||
new THREE.Color(1,0,0),
|
||||
new THREE.Color(0,1,0),
|
||||
new THREE.Color(0,0,1)
|
||||
];
|
||||
|
||||
// this.instance.color.r = 1;
|
||||
// this.instance.color.g = 0;
|
||||
// this.instance.color.b = 0;
|
||||
|
||||
//
|
||||
// mesh.materials[this.materialIndex].emissive.r = 0.5;
|
||||
// mesh.materials[this.materialIndex].emissive.g = 0.5;
|
||||
// mesh.materials[this.materialIndex].emissive.b = 0.5;
|
||||
// mesh.materials[this.materialIndex].updateInstance('emissive');
|
||||
|
||||
mesh.materials[this.materialIndex].vertexColors = R3.D3.API.Material.TYPE_VERTEX_COLORS;
|
||||
mesh.materials[this.materialIndex].updateInstance('vertexColors');
|
||||
|
||||
mesh.instance.geometry.elementsNeedUpdate = true;
|
||||
if (property === 'normal') {
|
||||
this.instance.normal = new R3.Vector3(
|
||||
this,
|
||||
this.normal
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
R3.Component.prototype.updateInstance.call(this, property);
|
||||
};
|
||||
|
||||
R3.D3.Face.prototype.removeHelper = function(mesh) {
|
||||
|
||||
this.instance.color.r = this.backupProperties.color.r;
|
||||
this.instance.color.g = this.backupProperties.color.g;
|
||||
this.instance.color.b = this.backupProperties.color.b;
|
||||
|
||||
mesh.instance.geometry.colorsNeedUpdate = true;
|
||||
|
||||
// mesh.materials[this.materialIndex].emissive.r = this.backupProperties.material.emissive.r;
|
||||
// mesh.materials[this.materialIndex].emissive.g = this.backupProperties.material.emissive.g;
|
||||
// mesh.materials[this.materialIndex].emissive.b = this.backupProperties.material.emissive.b;
|
||||
// mesh.materials[this.materialIndex].updateInstance('emissive');
|
||||
|
||||
mesh.materials[this.materialIndex].vertexColors = this.backupProperties.vertexColors;
|
||||
mesh.materials[this.materialIndex].updateInstance('vertexColors');
|
||||
|
||||
R3.D3.Face.prototype.createHelper = function() {
|
||||
console.warn('todo: implement R3.D3.Face.prototype.createHelper()');
|
||||
};
|
||||
|
||||
R3.D3.Face.prototype.removeHelper = function() {
|
||||
console.warn('todo: implement R3.D3.Face.prototype.removeHelper()');
|
||||
};
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
* R3.D3.Fog.Exp
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Fog.Exp = function(
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
__RUNTIME_COMPONENT_MACRO__;
|
||||
|
||||
R3.D3.API.Fog.Exp.call(
|
||||
this,
|
||||
apiComponent,
|
||||
apiComponent.density
|
||||
);
|
||||
|
||||
R3.D3.Fog.call(this);
|
||||
};
|
||||
|
||||
R3.D3.Fog.Exp.prototype = Object.create(R3.D3.Fog.prototype);
|
||||
R3.D3.Fog.Exp.prototype.constructor = R3.D3.Fog.Exp;
|
||||
|
||||
R3.D3.Fog.Exp.prototype.createInstance = function() {
|
||||
|
||||
this.instance = this.graphics.FogExp(
|
||||
this.color,
|
||||
this.density
|
||||
);
|
||||
|
||||
R3.Component.prototype.createInstance.call(this);
|
||||
};
|
||||
|
||||
R3.D3.Fog.Exp.prototype.updateInstance = function(property) {
|
||||
|
||||
if (property === 'density') {
|
||||
this.graphics.updateInstance(this, property);
|
||||
return;
|
||||
}
|
||||
|
||||
R3.D3.Fog.prototype.updateInstance.call(this, property);
|
||||
};
|
|
@ -0,0 +1,47 @@
|
|||
/**
|
||||
* R3.D3.Fog.Normal
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Fog.Normal = function(
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
__RUNTIME_COMPONENT_MACRO__;
|
||||
|
||||
R3.D3.API.Fog.Normal.call(
|
||||
this,
|
||||
apiComponent,
|
||||
apiComponent.near,
|
||||
apiComponent.far
|
||||
);
|
||||
|
||||
R3.D3.Fog.call(this);
|
||||
};
|
||||
|
||||
R3.D3.Fog.Normal.prototype = Object.create(R3.D3.Fog.prototype);
|
||||
R3.D3.Fog.Normal.prototype.constructor = R3.D3.Fog.Normal;
|
||||
|
||||
R3.D3.Fog.Normal.prototype.createInstance = function() {
|
||||
|
||||
this.instance = this.graphics.Fog(
|
||||
this.color,
|
||||
this.near,
|
||||
this.far
|
||||
);
|
||||
|
||||
R3.Component.prototype.createInstance.call(this);
|
||||
};
|
||||
|
||||
R3.D3.Fog.Normal.prototype.updateInstance = function(property) {
|
||||
|
||||
if (
|
||||
property === 'near' ||
|
||||
property === 'far'
|
||||
) {
|
||||
this.graphics.updateInstance(this, property);
|
||||
return;
|
||||
}
|
||||
|
||||
R3.D3.Fog.prototype.updateInstance.call(this, property);
|
||||
};
|
109
src/r3-d3-fog.js
109
src/r3-d3-fog.js
|
@ -1,37 +1,12 @@
|
|||
/**
|
||||
* Fog Superset - The apiFog properties get moved into the Fog object itself, and then the instance is
|
||||
* created
|
||||
* @param graphics
|
||||
* @param apiFog R3.D3.API.Fog
|
||||
* R3.D3.Fog
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Fog = function(
|
||||
graphics,
|
||||
apiFog
|
||||
) {
|
||||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(apiFog)) {
|
||||
apiFog = {};
|
||||
}
|
||||
|
||||
R3.D3.API.Fog.call(
|
||||
this,
|
||||
apiFog.id,
|
||||
apiFog.name,
|
||||
apiFog.exponential,
|
||||
apiFog.color,
|
||||
apiFog.near,
|
||||
apiFog.far,
|
||||
apiFog.density,
|
||||
apiFog.parent
|
||||
);
|
||||
R3.D3.Fog = function() {
|
||||
|
||||
this.color = new R3.Color(
|
||||
this.graphics,
|
||||
this.color,
|
||||
this
|
||||
this,
|
||||
this.color
|
||||
);
|
||||
|
||||
R3.Component.call(this);
|
||||
|
@ -40,55 +15,14 @@ R3.D3.Fog = function(
|
|||
R3.D3.Fog.prototype = Object.create(R3.Component.prototype);
|
||||
R3.D3.Fog.prototype.constructor = R3.D3.Fog;
|
||||
|
||||
/**
|
||||
* Creates an instance scene
|
||||
* @returns {THREE.Fog}
|
||||
*/
|
||||
R3.D3.Fog.prototype.createInstance = function() {
|
||||
|
||||
if (this.exponential) {
|
||||
|
||||
this.instance = new THREE.FogExp2(
|
||||
this.color.instance,
|
||||
this.density
|
||||
);
|
||||
|
||||
} else {
|
||||
|
||||
this.instance = new THREE.Fog(
|
||||
this.color.instance,
|
||||
this.near,
|
||||
this.far
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
this.instance.name = this.name;
|
||||
|
||||
R3.Component.prototype.createInstance.call(this);
|
||||
console.warn('This class should not be instantiated directly');
|
||||
|
||||
};
|
||||
|
||||
R3.D3.Fog.prototype.updateInstance = function(property) {
|
||||
|
||||
if (property === 'exponential') {
|
||||
if (
|
||||
this.exponential &&
|
||||
!(this.instance instanceof THREE.FogExp2)
|
||||
) {
|
||||
this.createInstance();
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
!this.exponential &&
|
||||
!(this.instance instanceof THREE.Fog)
|
||||
) {
|
||||
this.createInstance();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (property === 'color') {
|
||||
this.color.instance.setRGB(
|
||||
this.color.r,
|
||||
|
@ -96,39 +30,8 @@ R3.D3.Fog.prototype.updateInstance = function(property) {
|
|||
this.color.b
|
||||
);
|
||||
this.instance.color = this.color.instance;
|
||||
}
|
||||
|
||||
if (property === 'near' || property === 'far') {
|
||||
if (this.instance instanceof THREE.Fog) {
|
||||
this.instance.near = this.near;
|
||||
this.instance.far = this.far;
|
||||
}
|
||||
}
|
||||
|
||||
if (property === 'density') {
|
||||
if (this.instance instanceof THREE.FogExp2) {
|
||||
this.instance.density = this.density;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
R3.Component.prototype.updateInstance.call(this, property);
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a R3.D3.Fog to a R3.D3.API.Fog
|
||||
* @returns {R3.D3.API.Fog}
|
||||
*/
|
||||
R3.D3.Fog.prototype.toApiObject = function() {
|
||||
|
||||
return new R3.D3.API.Fog(
|
||||
this.id,
|
||||
this.name,
|
||||
this.exponential,
|
||||
this.color.toApiObject(),
|
||||
this.near,
|
||||
this.far,
|
||||
this.density,
|
||||
R3.Utils.IdOrNull(this.parent)
|
||||
);
|
||||
|
||||
};
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
/**
|
||||
* Font Superset - The apiFont properties get moved into the Font object itself, and then the instance is created
|
||||
* @param graphics R3.Runtime.Graphics
|
||||
* @param apiFont R3.D3.API.Font
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Font = function(
|
||||
graphics,
|
||||
apiFont
|
||||
) {
|
||||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(apiFont)) {
|
||||
apiFont = {};
|
||||
}
|
||||
|
||||
R3.D3.API.Font.call(
|
||||
this,
|
||||
apiFont.id,
|
||||
apiFont.name,
|
||||
apiFont.url,
|
||||
apiFont.parent
|
||||
);
|
||||
|
||||
R3.Component.call(this);
|
||||
};
|
||||
|
||||
R3.D3.Font.prototype = Object.create(R3.Component.prototype);
|
||||
R3.D3.Font.prototype.constructor = R3.D3.Font;
|
||||
|
||||
/**
|
||||
* Creates a light instance
|
||||
* @returns {*}
|
||||
*/
|
||||
R3.D3.Font.prototype.createInstance = function() {
|
||||
|
||||
R3.Event.Emit(
|
||||
R3.Event.LOAD_FONT,
|
||||
{
|
||||
font : this
|
||||
},
|
||||
function(fontInstance) {
|
||||
this.instance = fontInstance;
|
||||
|
||||
console.log('font instance loaded');
|
||||
|
||||
R3.Component.prototype.createInstance.call(this);
|
||||
}.bind(this),
|
||||
function(error) {
|
||||
console.error(error);
|
||||
this.instance = null;
|
||||
R3.Component.prototype.createInstance.call(this);
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the instance with the current state
|
||||
*/
|
||||
R3.D3.Font.prototype.updateInstance = function(property) {
|
||||
|
||||
if (property === 'url') {
|
||||
this.createInstance();
|
||||
}
|
||||
|
||||
R3.Component.prototype.updateInstance.call(this, property);
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a R3.D3.Font to a R3.D3.API.Font
|
||||
* @returns {R3.D3.API.Font}
|
||||
*/
|
||||
R3.D3.Font.prototype.toApiObject = function() {
|
||||
return new R3.D3.API.Font(
|
||||
this.id,
|
||||
this.name,
|
||||
this.url,
|
||||
R3.Utils.IdOrNull(this.parent)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a new R3.D3.Font from a R3.D3.API.Font
|
||||
* @param graphics R3.Runtime.Graphics
|
||||
* @param objectFont R3.D3.API.Font
|
||||
* @returns {R3.D3.Font}
|
||||
*/
|
||||
R3.D3.Font.FromObject = function(graphics, objectFont) {
|
||||
|
||||
return new R3.D3.Font(
|
||||
graphics,
|
||||
R3.D3.API.Font.FromObject(objectFont)
|
||||
);
|
||||
|
||||
};
|
|
@ -1,33 +1,24 @@
|
|||
/**
|
||||
* FrictionContactMaterial Runtime
|
||||
* @param physics R3.Runtime.Graphics
|
||||
* @param apiFrictionContactMaterial R3.D3.API.FrictionContactMaterial
|
||||
* R3.D3.FrictionContactMaterial
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.FrictionContactMaterial = function(
|
||||
physics,
|
||||
apiFrictionContactMaterial
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
this.physics = physics;
|
||||
this.physics.isNotCannonThrow();
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(apiFrictionContactMaterial)) {
|
||||
apiFrictionContactMaterial = {};
|
||||
}
|
||||
__RUNTIME_COMPONENT_MACRO__;
|
||||
|
||||
R3.D3.API.FrictionContactMaterial.call(
|
||||
this,
|
||||
apiFrictionContactMaterial.id,
|
||||
apiFrictionContactMaterial.name,
|
||||
apiFrictionContactMaterial.materials,
|
||||
apiFrictionContactMaterial.friction,
|
||||
apiFrictionContactMaterial.restitution,
|
||||
apiFrictionContactMaterial.contactEquationStiffness,
|
||||
apiFrictionContactMaterial.contactEquationRelaxation,
|
||||
apiFrictionContactMaterial.frictionEquationStiffness,
|
||||
apiFrictionContactMaterial.frictionEquationRelaxation,
|
||||
apiFrictionContactMaterial.parent
|
||||
apiComponent,
|
||||
apiComponent.materials,
|
||||
apiComponent.friction,
|
||||
apiComponent.restitution,
|
||||
apiComponent.contactEquationStiffness,
|
||||
apiComponent.contactEquationRelaxation,
|
||||
apiComponent.frictionEquationStiffness,
|
||||
apiComponent.frictionEquationRelaxation
|
||||
);
|
||||
|
||||
R3.Component.call(
|
||||
|
@ -47,20 +38,11 @@ R3.D3.FrictionContactMaterial.prototype.constructor = R3.D3.FrictionContactMater
|
|||
*/
|
||||
R3.D3.FrictionContactMaterial.prototype.createInstance = function() {
|
||||
|
||||
this.instance = new CANNON.ContactMaterial(
|
||||
null,
|
||||
null,
|
||||
{
|
||||
friction: this.friction,
|
||||
restitution: this.restitution,
|
||||
contactEquationStiffness: this.contactEquationStiffness
|
||||
}
|
||||
);
|
||||
|
||||
this.instance.materials = this.materials.map(
|
||||
function(material){
|
||||
return material.instance;
|
||||
}
|
||||
this.instance = this.physics.ContactMaterial(
|
||||
this.friction,
|
||||
this.restitution,
|
||||
this.contactEquationStiffness,
|
||||
this.materials
|
||||
);
|
||||
|
||||
R3.Component.prototype.createInstance.call(this);
|
||||
|
@ -69,61 +51,43 @@ R3.D3.FrictionContactMaterial.prototype.createInstance = function() {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
R3.D3.FrictionContactMaterial.prototype.updateInstance = function() {
|
||||
R3.D3.FrictionContactMaterial.prototype.updateInstance = function(property) {
|
||||
|
||||
this.instance.materials = this.materials.map(
|
||||
function(material) {
|
||||
return material.instance;
|
||||
if (property === 'materials') {
|
||||
this.physics.updateInstance(this, property);
|
||||
return;
|
||||
}
|
||||
);
|
||||
|
||||
this.instance.friction = this.friction;
|
||||
this.instance.restitution = this.restitution;
|
||||
this.instance.contactEquationStiffness = this.contactEquationStiffness;
|
||||
this.instance.contactEquationRelaxation = this.contactEquationRelaxation;
|
||||
this.instance.frictionEquationStiffness = this.frictionEquationStiffness;
|
||||
this.instance.frictionEquationRelaxation = this.frictionEquationRelaxation;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* R3.D3.FrictionContactMaterial to R3.D3.API.FrictionContactMaterial
|
||||
* @returns {R3.D3.API.FrictionContactMaterial}
|
||||
*/
|
||||
R3.D3.FrictionContactMaterial.prototype.toApiObject = function() {
|
||||
|
||||
var apiFrictionContactMaterial = new R3.D3.API.FrictionContactMaterial(
|
||||
this.id,
|
||||
this.name,
|
||||
this.materials.map(
|
||||
function(material) {
|
||||
return R3.Utils.IdOrNull(material);
|
||||
if (property === 'friction') {
|
||||
this.physics.updateInstance(this, property);
|
||||
return;
|
||||
}
|
||||
),
|
||||
this.friction,
|
||||
this.restitution,
|
||||
this.contactEquationStiffness,
|
||||
this.contactEquationRelaxation,
|
||||
this.frictionEquationStiffness,
|
||||
this.frictionEquationRelaxation,
|
||||
R3.Utils.IdOrNull(this.parent)
|
||||
);
|
||||
return apiFrictionContactMaterial;
|
||||
};
|
||||
|
||||
/**
|
||||
* R3.D3.FrictionContactMaterial from Object FrictionContactMaterial
|
||||
* @param physics
|
||||
* @param objectComponent
|
||||
* @returns {R3.D3.FrictionContactMaterial}
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.FrictionContactMaterial.FromObject = function(physics, objectComponent) {
|
||||
|
||||
var apiFrictionContactMaterial = R3.D3.API.FrictionContactMaterial.FromObject(objectComponent);
|
||||
|
||||
return new R3.D3.FrictionContactMaterial(
|
||||
physics,
|
||||
apiFrictionContactMaterial
|
||||
);
|
||||
|
||||
if (property === 'restitution') {
|
||||
this.physics.updateInstance(this, property);
|
||||
return;
|
||||
}
|
||||
|
||||
if (property === 'contactEquationStiffness') {
|
||||
this.physics.updateInstance(this, property);
|
||||
return;
|
||||
}
|
||||
|
||||
if (property === 'contactEquationRelaxation') {
|
||||
this.physics.updateInstance(this, property);
|
||||
return;
|
||||
}
|
||||
|
||||
if (property === 'frictionEquationStiffness') {
|
||||
this.physics.updateInstance(this, property);
|
||||
return;
|
||||
}
|
||||
|
||||
if (property === 'frictionEquationRelaxation') {
|
||||
this.physics.updateInstance(this, property);
|
||||
return;
|
||||
}
|
||||
|
||||
R3.Component.prototype.updateInstance(property);
|
||||
|
||||
};
|
||||
|
|
|
@ -1,28 +1,19 @@
|
|||
/**
|
||||
* FrictionMaterial Runtime
|
||||
* @param physics R3.Runtime.Graphics
|
||||
* @param apiFrictionMaterial R3.D3.API.FrictionMaterial
|
||||
* R3.D3.FrictionMaterial
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.FrictionMaterial = function(
|
||||
physics,
|
||||
apiFrictionMaterial
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
this.physics = physics;
|
||||
this.physics.isNotCannonThrow();
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(apiFrictionMaterial)) {
|
||||
apiFrictionMaterial = {};
|
||||
}
|
||||
__RUNTIME_COMPONENT_MACRO__;
|
||||
|
||||
R3.D3.API.FrictionMaterial.call(
|
||||
this,
|
||||
apiFrictionMaterial.id,
|
||||
apiFrictionMaterial.name,
|
||||
apiFrictionMaterial.friction,
|
||||
apiFrictionMaterial.restitution,
|
||||
apiFrictionMaterial.parent
|
||||
apiComponent,
|
||||
apiComponent.friction,
|
||||
apiComponent.restitution
|
||||
);
|
||||
|
||||
R3.Component.call(this);
|
||||
|
@ -36,55 +27,30 @@ R3.D3.FrictionMaterial.prototype.constructor = R3.D3.FrictionMaterial;
|
|||
*/
|
||||
R3.D3.FrictionMaterial.prototype.createInstance = function() {
|
||||
|
||||
this.instance = new CANNON.Material(
|
||||
this.name
|
||||
this.instance = this.physics.Material(
|
||||
this.name,
|
||||
this.friction,
|
||||
this.restitution
|
||||
);
|
||||
|
||||
this.instance.friction = this.friction;
|
||||
this.instance.restitution = this.restitution;
|
||||
|
||||
R3.Component.prototype.createInstance.call(this);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
R3.D3.FrictionMaterial.prototype.updateInstance = function() {
|
||||
this.instance.friction = this.friction;
|
||||
this.instance.restitution = this.restitution;
|
||||
this.instance.name = this.name;
|
||||
};
|
||||
|
||||
/**
|
||||
* R3.D3.FrictionMaterial to R3.D3.API.FrictionMaterial
|
||||
* @returns {R3.D3.API.FrictionMaterial}
|
||||
*/
|
||||
R3.D3.FrictionMaterial.prototype.toApiObject = function() {
|
||||
|
||||
var apiFrictionMaterial = new R3.D3.API.FrictionMaterial(
|
||||
this.id,
|
||||
this.name,
|
||||
this.friction,
|
||||
this.restitution,
|
||||
R3.Utils.IdOrNull(this.parent)
|
||||
);
|
||||
|
||||
return apiFrictionMaterial;
|
||||
};
|
||||
|
||||
/**
|
||||
* R3.D3.FrictionMaterial from Object FrictionMaterial
|
||||
* @param physics
|
||||
* @param objectComponent
|
||||
* @returns {R3.D3.FrictionMaterial}
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.FrictionMaterial.FromObject = function(physics, objectComponent) {
|
||||
|
||||
var apiFrictionMaterial = R3.D3.API.FrictionMaterial.FromObject(objectComponent);
|
||||
|
||||
return new R3.D3.FrictionMaterial(
|
||||
physics,
|
||||
apiFrictionMaterial
|
||||
);
|
||||
R3.D3.FrictionMaterial.prototype.updateInstance = function(property) {
|
||||
|
||||
if (property === 'friction') {
|
||||
this.physics.updateInstance(this, property);
|
||||
return;
|
||||
}
|
||||
|
||||
if (property === 'restitution') {
|
||||
this.physics.updateInstance(this, property);
|
||||
return;
|
||||
}
|
||||
|
||||
R3.Component.prototype.updateInstance.call(this, property);
|
||||
|
||||
};
|
||||
|
|
|
@ -1,93 +1,69 @@
|
|||
/**
|
||||
* R3.D3.Geometry
|
||||
* @param graphics
|
||||
* @param apiGeometry
|
||||
* @property geometryType
|
||||
* @param apiComponent
|
||||
* @param linkedObjects
|
||||
* @constructor
|
||||
*/
|
||||
R3.D3.Geometry = function(
|
||||
graphics,
|
||||
apiGeometry
|
||||
apiComponent,
|
||||
linkedObjects
|
||||
) {
|
||||
|
||||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
if (R3.Utils.UndefinedOrNull(linkedObjects)) {
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(apiGeometry)) {
|
||||
apiGeometry = {
|
||||
geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_NONE
|
||||
};
|
||||
}
|
||||
__RUNTIME_COMPONENT_MACRO__;
|
||||
|
||||
R3.D3.API.Geometry.call(
|
||||
this,
|
||||
apiGeometry.id,
|
||||
apiGeometry.name,
|
||||
apiGeometry.geometryType,
|
||||
apiGeometry.parent,
|
||||
apiGeometry.parentMesh,
|
||||
apiGeometry.boundingBox,
|
||||
apiGeometry.boundingSphere,
|
||||
apiGeometry.faces,
|
||||
apiGeometry.vertices
|
||||
apiComponent,
|
||||
apiComponent.boundingBox,
|
||||
apiComponent.boundingSphere,
|
||||
apiComponent.faces,
|
||||
apiComponent.vertices
|
||||
);
|
||||
|
||||
linkedObjects = {};
|
||||
}
|
||||
|
||||
this.boundingBox = new R3.Box3(
|
||||
this.graphics,
|
||||
this.boundingBox
|
||||
);
|
||||
|
||||
this.boundingSphere = new R3.Sphere(
|
||||
this.graphics,
|
||||
this.boundingSphere
|
||||
);
|
||||
|
||||
this.faces = this.faces.map(
|
||||
function(face) {
|
||||
return new R3.D3.Face(
|
||||
this.graphics,
|
||||
face
|
||||
)
|
||||
}.bind(this)
|
||||
linkedObjects.boundingBox = R3.Box3;
|
||||
linkedObjects.boundingSphere = R3.Sphere;
|
||||
|
||||
this.faces = this.faces.reduce(
|
||||
function(result, face) {
|
||||
if (face instanceof R3.D3.API.Face) {
|
||||
result.push(R3.Component.ConstructFromObject(face));
|
||||
} else {
|
||||
result.push(face);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
this.vertices = this.vertices.map(
|
||||
function(vertex) {
|
||||
return new R3.D3.Vertex(
|
||||
this.graphics,
|
||||
vertex
|
||||
)
|
||||
}.bind(this)
|
||||
function(result, vertex) {
|
||||
if (vertex instanceof R3.D3.API.Vertex) {
|
||||
result.push(R3.Component.ConstructFromObject(vertex));
|
||||
} else {
|
||||
result.push(vertex);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
var linkedObjects = {};
|
||||
|
||||
switch (this.geometryType) {
|
||||
case R3.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EDGES :
|
||||
case R3.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_WIREFRAME :
|
||||
linkedObjects.geometry = R3.D3.Geometry;
|
||||
break;
|
||||
case R3.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EXTRUDE :
|
||||
case R3.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SHAPE :
|
||||
linkedObjects.shapes = [R3.Curve.Path.D2.Shape];
|
||||
break;
|
||||
case R3.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TEXT :
|
||||
linkedObjects.font = R3.D3.Font;
|
||||
break;
|
||||
case R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_EXTRUDE:
|
||||
case R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SHAPE :
|
||||
linkedObjects.shapes = [R3.Curve.Path.D2.Shape];
|
||||
break;
|
||||
case R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TEXT :
|
||||
linkedObjects.font = R3.D3.Font;
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
if (this instanceof R3.D3.Geometry.Buffer) {
|
||||
linkedObjects.groups = [R3.Group];
|
||||
}
|
||||
linkedObjects.boundingBox = R3.Box3;
|
||||
linkedObjects.boundingSphere = R3.Sphere;
|
||||
linkedObjects.faces = [R3.D3.Face];
|
||||
linkedObjects.vertices = [R3.D3.Vertex];
|
||||
|
||||
R3.Component.call(
|
||||
this,
|
||||
|
|
|
@ -46,7 +46,6 @@ R3.EntityManager = function(apiEntityManager) {
|
|||
this.entityLoaded.bind(this)
|
||||
);
|
||||
|
||||
|
||||
R3.Component.call(
|
||||
this,
|
||||
{
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* R3.Font
|
||||
* @param apiComponent
|
||||
* @constructor
|
||||
*/
|
||||
R3.Font = function(
|
||||
apiComponent
|
||||
) {
|
||||
|
||||
__RUNTIME_COMPONENT_MACRO__;
|
||||
|
||||
R3.D3.API.Font.call(
|
||||
this,
|
||||
apiComponent,
|
||||
apiComponent.path
|
||||
);
|
||||
|
||||
R3.Component.call(this);
|
||||
};
|
||||
|
||||
R3.Font.prototype = Object.create(R3.Component.prototype);
|
||||
R3.Font.prototype.constructor = R3.Font;
|
||||
|
||||
/**
|
||||
* Creates a light instance
|
||||
* @returns {*}
|
||||
*/
|
||||
R3.Font.prototype.createInstance = function() {
|
||||
|
||||
R3.Event.Emit(
|
||||
R3.Event.LOAD_FONT,
|
||||
{
|
||||
font : this
|
||||
},
|
||||
function(fontInstance) {
|
||||
|
||||
this.instance = fontInstance;
|
||||
|
||||
console.log('font instance loaded');
|
||||
|
||||
R3.Component.prototype.createInstance.call(this);
|
||||
}.bind(this),
|
||||
function(error) {
|
||||
console.error(error);
|
||||
this.instance = null;
|
||||
R3.Component.prototype.createInstance.call(this);
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the instance with the current state
|
||||
*/
|
||||
R3.Font.prototype.updateInstance = function(property) {
|
||||
|
||||
if (property === 'path') {
|
||||
this.createInstance();
|
||||
}
|
||||
|
||||
R3.Component.prototype.updateInstance.call(this, property);
|
||||
};
|
|
@ -35,7 +35,7 @@ R3.Runtime.Graphics.Three.prototype.Vector4 = function(x,y,z,w) {
|
|||
};
|
||||
|
||||
R3.Runtime.Graphics.Three.prototype.Color = function(r,g,b,a) {
|
||||
return new THREE.Color(r,g,b,a);
|
||||
return new THREE.Color(r,g,b);
|
||||
};
|
||||
|
||||
R3.Runtime.Graphics.Three.prototype.Matrix4 = function(rows) {
|
||||
|
@ -558,3 +558,100 @@ R3.Runtime.Graphics.Three.prototype.StereoEffect = function(
|
|||
renderer.instance
|
||||
);
|
||||
};
|
||||
|
||||
R3.Runtime.Graphics.Three.prototype.Face = function(
|
||||
v0index,
|
||||
v1index,
|
||||
v2index,
|
||||
normal,
|
||||
color,
|
||||
materialIndex,
|
||||
vertexColors
|
||||
) {
|
||||
var face = new THREE.Face3(
|
||||
v0index,
|
||||
v1index,
|
||||
v2index
|
||||
);
|
||||
|
||||
if (normal) {
|
||||
face.normal = new THREE.Vector3(
|
||||
normal.x,
|
||||
normal.y,
|
||||
normal.z
|
||||
);
|
||||
}
|
||||
|
||||
if (color) {
|
||||
face.color = new THREE.Color(
|
||||
color.r,
|
||||
color.g,
|
||||
color.b
|
||||
)
|
||||
}
|
||||
|
||||
if (materialIndex > -1) {
|
||||
face.materialIndex = materialIndex;
|
||||
}
|
||||
|
||||
vertexColors.map(
|
||||
function(vertexColor, index) {
|
||||
face.vertexColors[index] = new THREE.Color(vertexColor.r, vertexColor.g, vertexColor.b);
|
||||
}
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
R3.Runtime.Graphics.Three.prototype.FogExp = function(
|
||||
color,
|
||||
density
|
||||
) {
|
||||
return new THREE.FogExp2(
|
||||
this.color.toHex(),
|
||||
this.density
|
||||
);
|
||||
};
|
||||
|
||||
R3.Runtime.Graphics.Three.prototype.Fog = function(
|
||||
color,
|
||||
near,
|
||||
far
|
||||
) {
|
||||
return new THREE.Fog(
|
||||
this.color.toHex(),
|
||||
this.near,
|
||||
this.far
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* R3.Runtime.Graphics.Three.prototype.updateInstance
|
||||
* @param runtimeObject
|
||||
* @param property
|
||||
*/
|
||||
R3.Runtime.Graphics.Three.prototype.updateInstance = function (runtimeObject, property) {
|
||||
|
||||
var instance = runtimeObject.instance;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(instance)) {
|
||||
throw new Error('no instance available for update');
|
||||
}
|
||||
|
||||
if (instance instanceof THREE.FogExp2) {
|
||||
if (property === 'density') {
|
||||
instance[property] = runtimeObject[property];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (instance instanceof THREE.Fog) {
|
||||
if (
|
||||
property === 'near' ||
|
||||
property === 'far'
|
||||
) {
|
||||
instance[property] = runtimeObject[property];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
|
@ -175,3 +175,35 @@ R3.Runtime.Graphics.prototype.StereoEffect = function(
|
|||
) {
|
||||
console.warn('override StereoEffect in child class');
|
||||
};
|
||||
|
||||
R3.Runtime.Graphics.prototype.Face = function(
|
||||
v0index,
|
||||
v1index,
|
||||
v2index,
|
||||
normal,
|
||||
color,
|
||||
materialIndex,
|
||||
vertexColors
|
||||
) {
|
||||
console.warn('override Face in child class');
|
||||
};
|
||||
|
||||
R3.Runtime.Graphics.prototype.FogExp = function(
|
||||
color,
|
||||
density
|
||||
) {
|
||||
console.warn('override R3.Runtime.Graphics.prototype.FogExp in child class');
|
||||
};
|
||||
|
||||
R3.Runtime.Graphics.prototype.Fog = function(
|
||||
color,
|
||||
near,
|
||||
far
|
||||
) {
|
||||
console.warn('override R3.Runtime.Graphics.prototype.Fog in child class');
|
||||
};
|
||||
|
||||
R3.Runtime.Graphics.prototype.updateInstance = function (runtimeObject, property) {
|
||||
console.warn('override R3.Runtime.Graphics.prototype.updateInstance in child class');
|
||||
};
|
||||
|
||||
|
|
|
@ -58,3 +58,87 @@ R3.Runtime.Physics.Cannon.prototype.Broadphase = function(broadphaseType) {
|
|||
}
|
||||
|
||||
};
|
||||
|
||||
R3.Runtime.Physics.Cannon.prototype.ContactMaterial = function(
|
||||
friction,
|
||||
restitution,
|
||||
contactEquationStiffness,
|
||||
materials,
|
||||
) {
|
||||
var instance = new CANNON.ContactMaterial(
|
||||
null,
|
||||
null,
|
||||
{
|
||||
friction: this.friction,
|
||||
restitution: this.restitution,
|
||||
contactEquationStiffness: this.contactEquationStiffness
|
||||
}
|
||||
);
|
||||
|
||||
instance.materials = this.materials.map(
|
||||
function(material){
|
||||
return material.instance;
|
||||
}
|
||||
);
|
||||
|
||||
return instance;
|
||||
};
|
||||
|
||||
R3.Runtime.Physics.Cannon.prototype.Material = function(
|
||||
name,
|
||||
friction,
|
||||
restitution
|
||||
) {
|
||||
var instance = new CANNON.Material(
|
||||
name
|
||||
);
|
||||
|
||||
instance.friction = friction;
|
||||
instance.restitution = restitution;
|
||||
|
||||
return instance;
|
||||
};
|
||||
|
||||
R3.Runtime.Physics.Cannon.prototype.updateInstance = function(runtimeObject, property) {
|
||||
|
||||
var instance = runtimeObject.instance;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(instance)) {
|
||||
throw new Error('no instance available for update');
|
||||
}
|
||||
|
||||
if (instance instanceof CANNON.ContactMaterial) {
|
||||
|
||||
if (
|
||||
property === 'friction' ||
|
||||
property === 'restitution' ||
|
||||
property === 'contactEquationStiffness' ||
|
||||
property === 'contactEquationRelaxation' ||
|
||||
property === 'frictionEquationStiffness' ||
|
||||
property === 'frictionEquationRelaxation'
|
||||
) {
|
||||
instance[property] = runtimeObject[property];
|
||||
return;
|
||||
}
|
||||
|
||||
if (property === 'materials') {
|
||||
instance.materials = runtimeObject.materials.map(
|
||||
function(material) {
|
||||
return material.instance;
|
||||
}
|
||||
);
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (instance instanceof CANNON.Material) {
|
||||
if (
|
||||
property === 'friction' ||
|
||||
property === 'restitution'
|
||||
) {
|
||||
instance[property] = runtimeObject[property];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
|
@ -38,3 +38,24 @@ R3.Runtime.Physics.prototype.Quaternion = function(x,y,z,w) {
|
|||
R3.Runtime.Physics.prototype.Broadphase = function(broadphaseType) {
|
||||
console.log('override Quaternion in child class')
|
||||
};
|
||||
|
||||
R3.Runtime.Physics.prototype.ContactMaterial = function(
|
||||
friction,
|
||||
restitution,
|
||||
contactEquationStiffness,
|
||||
materials,
|
||||
) {
|
||||
console.log('override R3.Runtime.Physics.prototype.ContactMaterial in child class');
|
||||
};
|
||||
|
||||
R3.Runtime.Physics.prototype.Material = function(
|
||||
name,
|
||||
friction,
|
||||
restitution
|
||||
) {
|
||||
console.log('override R3.Runtime.Physics.prototype.Material in child class')
|
||||
};
|
||||
|
||||
R3.Runtime.Physics.prototype.updateInstance = function(runtimeObject, property) {
|
||||
console.log('override R3.Runtime.Physics.prototype.updateInstance in child class');
|
||||
};
|
Loading…
Reference in New Issue