restructuring

beta.r3js.org
cybafelo 2019-07-25 22:22:32 +02:00
parent 567b6b9f38
commit b28b1bc99b
258 changed files with 2274 additions and 2831 deletions

View File

@ -17,7 +17,7 @@ code += '\t\tthis,\n';
code += '\t\tthis.apiComponent.parent,\n';
code += '\t\tthis.apiComponent.id,\n';
code += '\t\tthis.apiComponent.name\n';
code += '\t);';
code += '\t)';
var code2 = 'if (R3.Utils.UndefinedOrNull(apiGeometryBuffer)) {\n';
code2 += '\t\tapiGeometryBuffer = {};\n';
@ -32,7 +32,7 @@ code2 += '\t\tthis.apiGeometryBuffer.drawRange,\n';
code2 += '\t\tthis.apiGeometryBuffer.groups,\n';
code2 += '\t\tthis.apiGeometryBuffer.index,\n';
code2 += '\t\tthis.apiGeometryBuffer.morphAttributes\n';
code2 += '\t);';
code2 += '\t)';
var code3 = 'if (R3.Utils.UndefinedOrNull(apiGeometryNormal)) {\n';
code3 += '\t\tapiGeometryNormal = {};\n';
@ -55,7 +55,7 @@ code3 += '\t\tthis.apiGeometryNormal.normalsNeedUpdate,\n';
code3 += '\t\tthis.apiGeometryNormal.colorsNeedUpdate,\n';
code3 += '\t\tthis.apiGeometryNormal.groupsNeedUpdate,\n';
code3 += '\t\tthis.apiGeometryNormal.lineDistancesNeedUpdate\n';
code3 += '\t);';
code3 += '\t)';
var code4 = 'if (R3.Utils.UndefinedOrNull(apiMaterial)) {\n';
code4 += '\t\tapiMaterial = {};\n';
@ -99,7 +99,7 @@ code4 += '\t\tthis.apiMaterial.side,\n';
code4 += '\t\tthis.apiMaterial.transparent,\n';
code4 += '\t\tthis.apiMaterial.vertexColors,\n';
code4 += '\t\tthis.apiMaterial.visible\n';
code4 += '\t);';
code4 += '\t)';
var code5 = 'if (R3.Utils.UndefinedOrNull(apiTexture)) {\n';
code5 += '\t\tapiTexture = {};\n';
@ -133,7 +133,28 @@ code5 += '\t\tthis.apiTexture.version,\n';
code5 += '\t\tthis.apiTexture.animated,\n';
code5 += '\t\tthis.apiTexture.reverseAnimation,\n';
code5 += '\t\tthis.apiTexture.forward\n';
code5 += '\t);';
code5 += '\t)';
var code6 = 'if (R3.Utils.UndefinedOrNull(apiComponent)) {\n';
code6 += '\t\tapiComponent = {};\n';
code6 += '\t}\n';
code6 += '\tthis.apiComponent = apiComponent;\n';
code6 += '\n';
code6 += '\tthis.graphics\t= null;\n';
code6 += '\tthis.physics\t= null;\n';
code6 += '\tthis.gui\t\t= null;\n';
code6 += '\tthis.stats\t\t= null;\n';
code6 += '\n';
code6 += '\tR3.Event.Emit(\n';
code6 += '\t\tR3.Event.GET_RUNTIME,\n';
code6 += '\t\tfunction(runtime) {\n';
code6 += '\t\t\tthis.graphics\t= runtime.graphics;\n';
code6 += '\t\t\tthis.physics\t= runtime.physics;\n';
code6 += '\t\t\tthis.coder\t= runtime.coder;\n';
code6 += '\t\t\tthis.gui\t\t= runtime.gui;\n';
code6 += '\t\t\tthis.stats\t\t= runtime.stats;\n';
code6 += '\t\t}.bind(this)\n';
code6 += '\t)';
function build() {
return gulp.src('./src/r3-*.js')
@ -145,6 +166,7 @@ function build() {
.pipe(replace('__API_GEOMETRY_NORMAL_MACRO__', code3))
.pipe(replace('__API_MATERIAL_MACRO__', code4))
.pipe(replace('__API_TEXTURE_MACRO__', code5))
.pipe(replace('__RUNTIME_COMPONENT_MACRO__', code6))
.pipe(minify({
ext:{
src:'.js',

View File

@ -862,37 +862,37 @@ R3.Utils.IsEmpty = function(obj) {
return (Object.keys(obj).length === 0 && obj.constructor === Object);
};
R3.Utils.isString = function(member) {
R3.Utils.IsString = function(member) {
return (typeof member === 'string');
};
R3.Utils.isBoolean = function(member) {
R3.Utils.IsBoolean = function(member) {
return (member === true || member === false);
};
R3.Utils.isColor = function(member) {
R3.Utils.IsColor = function(member) {
return (member instanceof R3.Color);
};
R3.Utils.isNumber = function(member) {
R3.Utils.IsNumber = function(member) {
return (typeof member === 'number');
};
R3.Utils.isVector2 = function(member) {
R3.Utils.IsVector2 = function(member) {
return (
member instanceof R3.API.Vector2 ||
member instanceof R3.Vector2
);
};
R3.Utils.isVector3 = function(member) {
R3.Utils.IsVector3 = function(member) {
return (
member instanceof R3.API.Vector3 ||
member instanceof R3.Vector3
);
};
R3.Utils.isVector4 = function(member) {
R3.Utils.IsVector4 = function(member) {
return (
member instanceof R3.API.Vector4 ||
member instanceof R3.Vector4 ||
@ -901,6 +901,11 @@ R3.Utils.isVector4 = function(member) {
);
};
R3.Utils.IsObject = function(member) {
var type = typeof member;
return type === 'function' || type === 'object' && !!member;
};
/**
* @return {string}
*/

View File

@ -1,28 +1,33 @@
/**
* Component Interface
* @constructor
* @param linkedObjects
* R3.Component is an R3.Event
* @param parent
* @param linkedObjects
* @constructor
*/
R3.Component = function(
parent,
linkedObjects
) {
/**
* Call the Event constructor first so we can set the parent right away
*/
R3.Event.call(
this,
parent
);
this.componentType = this.getComponentType();
if (R3.Utils.UndefinedOrNull(parent)) {
parent = null;
}
this.parent = parent;
if (R3.Utils.UndefinedOrNull(linkedObjects)) {
linkedObjects = {};
}
this.linkedObjects = linkedObjects;
/**
* Call the Event constructor first so we can set the parent right away
*/
R3.Event.call(
this,
this.parent
);
this.componentType = this.getComponentType();
this.idToObject = {};
this.selected = false;
@ -200,29 +205,78 @@ R3.Component.prototype.getDependencies = function() {
};
R3.Component.prototype.updateInstance = function(property) {
console.warn('TODO: update instance for parent change');
//
// if (property === 'parent') {
//
// if (this.parent instanceof R3.Entity) {
// this.parent.addComponent(this);
//
// this.buildIdToObject();
//
// Object.keys(this.idToObject).map(
// function(componentId) {
//
// if (this.id !== componentId) {
// this.parent.addComponent(this.idToObject[componentId]);
// }
//
// }.bind(this)
// )
// }
//
// }
if (property === 'id') {
console.warn('TODO: update id');
return;
}
if (property === 'name') {
console.warn('TODO: update name');
return;
}
if (property === 'parent') {
console.warn('TODO: update parent');
return;
}
};
/**
* R3.Component.prototype.updateFromInstance
*
* - Updates the component by its instance data
*
* @param property
*/
R3.Component.prototype.updateFromInstance = function(property) {
if (
this[property] instanceof R3.Color
) {
this[property].r = this.instance[property].r;
this[property].g = this.instance[property].g;
this[property].b = this.instance[property].b;
this[property].a = this.instance[property].a;
}
if (
this[property] instanceof R3.Vector2
) {
this[property].x = this.instance[property].x;
this[property].y = this.instance[property].y;
}
if (
this[property] instanceof R3.Vector3
) {
this[property].x = this.instance[property].x;
this[property].y = this.instance[property].y;
this[property].z = this.instance[property].z;
}
if (
this[property] instanceof R3.Vector4 |
this[property] instanceof R3.Quaternion
) {
this[property].x = this.instance[property].x;
this[property].y = this.instance[property].y;
this[property].z = this.instance[property].z;
this[property].w = this.instance[property].w;
}
if (
this[property] instanceof R3.Matrix4
) {
throw new Error('TODO : implement this code - no use case yet');
}
if (R3.Utils.IsObject(this[property])) {
throw new Error('TODO : update component object from instance object');
}
this[property] = this.instance[property];
};
/**
@ -261,6 +315,28 @@ R3.Component.prototype.getParent = function(property, constructor) {
};
/**
* This function traverses the parent chain to find the first parent which matches the constructor
* @param constructor
*/
R3.Component.prototype.getFirstParent = function(constructor) {
if (R3.Utils.UndefinedOrNull(constructor)) {
throw new Error('You need to specify a constructor');
}
if (this.parent === null) {
return null;
}
if (this.parent instanceof constructor) {
return this.parent;
} else {
return this.getFirstParent(constructor);
}
};
R3.Component.prototype.toString = function() {
return this.id;
};
@ -573,9 +649,9 @@ R3.Component.GetComponentInfo = function(number) {
apiConstructor : R3.API.System
};
case 0x14 : return {
name : 'R3.GraphicsRuntime',
name : 'R3.Runtime.Graphics',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.GraphicsRuntime
constructor : R3.Runtime.Graphics
};
case 0x15 : return {
name : 'R3.D3.Helper',
@ -1944,7 +2020,7 @@ R3.Component.prototype.getComponentType = function() {
if (this instanceof R3.GUI) {
return R3.Component.GUI;
}
if (this instanceof R3.GUIRuntime) {
if (this instanceof R3.Runtime.GUI) {
return R3.Component.GUI_RUNTIME;
}
if (this instanceof R3.Image) {
@ -2017,6 +2093,39 @@ R3.Component.GetComponentConstructor = function(componentType) {
return null;
};
R3.Component.prototype.getPropertyValue = function(item) {
/**
* We found data that we need to process - here we have to pay attention.
* For linked objects - we only store the ID
*/
if (item instanceof R3.Component) {
return R3.Utils.IdOrNull(item);
}
/**
* Handle colors, vectors and matrices - they are not components so they have their own toApiObject functions
*/
if (
item instanceof R3.Color |
item instanceof R3.Vector2 |
item instanceof R3.Vector3 |
item instanceof R3.Vector4 |
item instanceof R3.Quaternion |
item instanceof R3.Matrix4
) {
return item.toApiObject();
}
/**
* If we get to this point and we still have an Object - we throw an error
*/
if (R3.Utils.IsObject(item)) {
throw new Error('We still have an object here which is trying to get saved: ' + item);
}
return item;
};
/**
* Components are linked at runtime - for storing, we just store the ID
@ -2028,15 +2137,65 @@ R3.Component.prototype.toApiObject = function() {
var apiConstructor = info.apiConstructor;
console.warn('implement generic component toApiObject');
var apiObject = new apiConstructor();
var parameters = R3.Utils.GetParameters(apiConstructor);
for (var property in apiObject) {
if (apiObject.hasOwnProperty(property)) {
throw new Error(parameters);
/**
* Check if the current component also has this property
*/
if (this.hasOwnProperty(property)) {
return this.id;
// return new info.apiConstructor()
if (this[property] instanceof R3.Runtime) {
/**
* Check if this is a runtime object - we ignore those
*/
continue;
}
/**
* Check if this property is an array of something
*/
if (this[property].isArray) {
/**
* Quick sanity check that the apiObject also thinks this is an array
*/
if (!arrayObject[property].isArray) {
throw new Error('The API Object ' + apiObject + ' does not seem to think ' + property + ' is an array');
}
/**
* Loop through the array - assign the contents of
* the array to the apiObject
*/
apiObject[property] = this[property].reduce(
function(result, item) {
if (item instanceof R3.Runtime) {
throw new Error('Please don\'t store Runtime Objects in Arrays');
}
result.push(this.getPropertyValue(item));
return result;
}.bind(this),
[]
);
} else {
/**
* This is not an array, so get the proper value directly from the property
*/
apiObject[property] = this.getPropertyValue(this[property]);
}
}
}
}
};
/**
@ -2436,7 +2595,7 @@ R3.Component.GetRuntimeObject = function(info) {
}
);
if (info.runtime === R3.Component.GRAPHICS_RUNTIME) {
if (info.runtime instanceof R3.Runtime.Graphics) {
if (R3.Utils.UndefinedOrNull(runtime.graphics)) {
console.warn('no runtime graphics: ', info);
@ -2523,4 +2682,4 @@ R3.Component.ConstructFromObject = function(rawComponentObject) {
}
return runtimeComponent;
};
};

View File

@ -7,7 +7,7 @@ R3.API.Clock = function(
apiComponent
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
};

View File

@ -9,7 +9,7 @@ R3.API.Controls = function(
canvas
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(canvas)) {
/**

View File

@ -9,7 +9,7 @@ R3.API.Curve = function(
arcLenghDivisions
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(arcLenghDivisions)) {
arcLenghDivisions = 200;

View File

@ -11,7 +11,7 @@ R3.API.CustomCode = function(
code
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(eventId)) {
eventId = R3.Event.KEY_UP;

View File

@ -9,7 +9,7 @@ R3.API.DomElement = function(
domElementId
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(domElementId)) {
domElementId = '';

View File

@ -11,7 +11,7 @@ R3.API.DrawRange = function(
count
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(start)) {
start = 0;

View File

@ -9,7 +9,7 @@ R3.API.EntityManager = function(
entities
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(entities)) {
entities = [];

View File

@ -9,7 +9,7 @@ R3.API.Entity = function(
components
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(components)) {
components = [];

View File

@ -13,7 +13,7 @@ R3.API.Group = function(
materialIndex
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(start)) {
start = 0;

View File

@ -9,7 +9,7 @@ R3.API.GUI = function(
domElement
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(domElement)) {
domElement = null;

View File

@ -21,7 +21,7 @@ R3.API.Image = function(
height
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(fileName)) {
fileName = R3.Utils.LowerUnderscore(name);

View File

@ -11,7 +11,7 @@ R3.API.Mouse = function(
y
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(x)) {
x = 0;

View File

@ -11,7 +11,7 @@ R3.API.Plane = function(
constant
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(normal)) {
normal = new R3.API.Vector3(1,0,0);

View File

@ -6,6 +6,7 @@
* @param entities
* @param renderers
* @param cameras
* @param audios
* @param mode
* @constructor
*/
@ -16,10 +17,11 @@ R3.API.Project = function(
entities,
renderers,
cameras,
audios,
mode
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(users)) {
throw new Error('Only registered users can create projects');
@ -56,6 +58,11 @@ R3.API.Project = function(
}
this.cameras = cameras;
if (R3.Utils.UndefinedOrNull(audios)) {
audios = [];
}
this.audios = audios;
if (R3.Utils.UndefinedOrNull(mode)) {
mode = R3.API.Project.APPLICATION_MODE_EDIT;
}

View File

@ -7,7 +7,7 @@ R3.API.Renderer = function(
apiComponent
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
};

View File

@ -23,7 +23,7 @@ R3.API.Server = function(
protocols
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(protocol)) {
protocol = R3.API.Server.PROTOCOL_HTTP_SSL;

View File

@ -13,7 +13,7 @@ R3.API.Socket = function(
server
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(roomId)) {
roomId = 'room_' + R3.Utils.RandomId();

View File

@ -11,7 +11,7 @@ R3.API.Sphere = function(
radius
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(center)) {
center = new R3.API.Vector3(0,0,0);

View File

@ -9,7 +9,7 @@ R3.API.Stats = function(
domElement
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(domElement)) {
domElement = null;

View File

@ -23,7 +23,7 @@ R3.API.User = function(
idToken
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(googleId)) {
throw new Error('invalid user - no google ID');

View File

@ -17,7 +17,7 @@ R3.API.Video = function(
source
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(autoUpdateSize)) {
autoUpdateSize = true;

View File

@ -1,29 +1,21 @@
/**
* R3.Box3
* @param parent
* @param apiBox3
* @param apiComponent
* @constructor
*/
R3.Box3 = function(
parent,
apiBox3
apiComponent
) {
if (R3.Utils.UndefinedOrNull(parent)) {
parent = null;
}
this.parent = parent;
if (R3.Utils.UndefinedOrNull(apiBox3)) {
apiBox3 = {};
}
this.apiBox3 = apiBox3;
__RUNTIME_COMPONENT_MACRO__;
R3.API.Box3.call(
this,
this.apiBox3,
this.apiBox3.min,
this.apiBox3.max
apiComponent,
apiComponent.min,
apiComponent.max
);
this.min = new R3.Vector3(
@ -36,20 +28,12 @@ R3.Box3 = function(
this.max
);
this.graphics = null;
this.physics = null;
R3.Event.Emit(
R3.Event.GET_RUNTIME,
function(runtime) {
this.graphics = runtime.graphics;
this.physics = runtime.physics;
}.bind(this)
);
this.componentRuntime = R3.Component.GetComponentRuntime(this.parent);
this.createInstance();
R3.Component.call(
this,
parent
);
};
R3.Box3.prototype = Object.create(R3.Component.prototype);
@ -90,27 +74,16 @@ R3.Box3.prototype.updateInstance = function(property) {
this.instance.min.x = this.min.x;
this.instance.min.y = this.min.y;
this.instance.min.z = this.min.z;
return;
}
if (property === 'max') {
this.instance.max.x = this.max.x;
this.instance.max.y = this.max.y;
this.instance.max.z = this.max.z;
return;
}
};
/**
* R3.Box3 to R3.API.Box3
* @returns {R3.API.Box3}
*/
R3.Box3.prototype.toApiObject = function() {
return new R3.API.Box3(
new R3.API.Component(
this.parent,
this.id,
this.name
),
this.min.toApiObject(),
this.max.toApiObject()
);
R3.Component.prototype.updateInstance.call(this, property);
};

View File

@ -1,50 +1,42 @@
/**
* Canvas object
* @param graphics
* @param apiCanvas
* @returns {R3.Canvas}
* R3.Canvas
* @param parent
* @param apiComponent
* @constructor
*/
R3.Canvas = function(
graphics,
apiCanvas
parent,
apiComponent
) {
this.graphics = graphics;
if (R3.Utils.UndefinedOrNull(apiCanvas)) {
apiCanvas = {};
}
__RUNTIME_COMPONENT_MACRO__;
R3.API.Canvas.call(
this,
apiCanvas.id,
apiCanvas.name,
apiCanvas.parent,
apiCanvas.parentTexture,
apiCanvas.autoUpdateSize,
apiCanvas.width,
apiCanvas.height,
apiCanvas.offset,
apiCanvas.tabIndex,
apiCanvas.texts,
apiCanvas.textBaseline
apiComponent,
apiComponent.autoUpdateSize,
apiComponent.width,
apiComponent.height,
apiComponent.offset,
apiComponent.tabIndex,
apiComponent.texts,
apiComponent.textBaseline
);
this.offset = new R3.Vector2(
this.graphics,
this.offset,
this
);
R3.Component.call(
this,
{
'parentTexture' : R3.D3.Texture,
'texts' : [R3.D3.Text]
}
this.offset
);
this.context = null;
R3.Component.call(
this,
parent,
{
'texts' : [R3.D3.Text]
}
);
};
R3.Canvas.prototype = Object.create(R3.Component.prototype);
@ -154,31 +146,10 @@ R3.Canvas.prototype.updateInstance = function(property) {
R3.Component.prototype.updateInstance.call(this, property);
};
/**
* Converts a R3.Canvas to a R3.API.Canvas
* @returns {R3.API.Canvas}
*/
R3.Canvas.prototype.toApiObject = function() {
return new R3.API.Canvas(
this.id,
this.name,
R3.Utils.IdOrNull(this.parent),
R3.Utils.IdOrNull(this.parentTexture),
this.autoUpdateSize,
this.width,
this.height,
this.offset.toApiObject(),
this.tabIndex,
this.texts.map(function(text){
return R3.Utils.IdOrNull(text)
}),
this.textBaseline
);
};
R3.Canvas.prototype.writeText = function() {
var parentTexture = this.getFirstParent(R3.D3.Texture);
this.clear();
this.texts.map(
@ -189,14 +160,12 @@ R3.Canvas.prototype.writeText = function() {
this.context = this.instance.getContext('2d');
}
text.parentCanvas = this;
this.context.fillStyle = text.fillStyle;
this.context.font = text.font;
this.context.fillText(text.value, text.offset.x, text.offset.y);
if (this.parentTexture && this.parentTexture.instance) {
this.parentTexture.instance.needsUpdate = true;
if (parentTexture && parentTexture.instance) {
parentTexture.instance.needsUpdate = true;
}
}.bind(this)

View File

@ -1,49 +1,47 @@
/**
* Creates a Clock object
* @param graphics
* @param apiClock R3.API.Clock
* R3.Clock
* @param parent
* @param apiComponent
* @constructor
*/
R3.Clock = function(
graphics,
apiClock
parent,
apiComponent
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (R3.Utils.UndefinedOrNull(apiClock)) {
apiClock = {};
}
__RUNTIME_COMPONENT_MACRO__;
R3.API.Clock.call(
this,
apiClock.id,
apiClock.name,
apiClock.parent
apiComponent
);
R3.Component.call(this);
R3.Component.call(
this,
parent
);
} ;
R3.Clock.prototype = Object.create(R3.Component.prototype);
R3.Clock.prototype.constructor = R3.Clock;
/**
* Creates a camera instance of 'graphics' type (only THREE for now)
* @returns {THREE.Clock}
* R3.Clock.prototype.createInstance
*/
R3.Clock.prototype.createInstance = function() {
this.instance = new THREE.Clock();
this.instance = this.graphics.Clock();
R3.Component.prototype.createInstance.call(this);
};
/**
* Updates the instance with the current state
* R3.Clock.prototype.updateInstance
* @param property
*/
R3.Clock.prototype.updateInstance = function() {
R3.Clock.prototype.updateInstance = function(property) {
R3.Component.prototype.updateInstance.call(this, property);
};
@ -54,7 +52,6 @@ R3.Clock.prototype.getDelta = function() {
/**
* clamp the delta to 1/60
*/
if (delta > (1 / 30.0)) {
// console.log('clipped ' + (delta - (1/30.0)) + ' seconds - essentially lost time');
delta = (1 / 30.0);
@ -62,35 +59,3 @@ R3.Clock.prototype.getDelta = function() {
return delta;
};
/**
* Converts a R3.Clock to a new R3.API.Clock
* @returns {R3.API.Clock}
*/
R3.Clock.prototype.toApiObject = function() {
return new R3.API.Clock(
this.id,
this.name,
R3.Utils.IdOrNull(this.parent)
);
};
/**
* Converts from an Object camera to a R3.Clock
* @param graphics R3.Graphics
* @param objectClock Object
* @returns {R3.Clock}
* @constructor
*/
R3.Clock.FromObject = function(graphics, objectClock) {
var apiClock = R3.API.Clock.FromObject(objectClock);
return new R3.Clock(
graphics,
apiClock
);
};

View File

@ -1,60 +0,0 @@
/**
* Coder
* @param id
* @param name
* @param coderType
* @constructor
*/
R3.CoderRuntime = function(
id,
name,
coderType
) {
if (R3.Utils.UndefinedOrNull(id)) {
id = R3.Utils.RandomId();
}
this.id = id;
if (R3.Utils.UndefinedOrNull(name)) {
name = 'Coder (' + id + ')';
}
this.name = name;
if (R3.Utils.UndefinedOrNull(coderType)) {
coderType = R3.CoderRuntime.TYPE_CODE_MIRROR;
}
this.coderType = coderType;
this.createInstance();
};
/**
* R3.CoderRuntime Types
* @type {number}
*/
R3.CoderRuntime.TYPE_CODE_MIRROR = 0x1;
R3.CoderRuntime.prototype.createInstance = function() {
if (this.coderType === R3.CoderRuntime.TYPE_CODE_MIRROR) {
this.instance = CodeMirror;
} else {
this.instance = null;
}
};
R3.CoderRuntime.prototype.updateInstance = function(property) {
if (property === 'coderType') {
this.createInstance();
}
};
/**
* Logs a warning and throws an error if not cannon
*/
R3.CoderRuntime.prototype.isNotCodeMirrorThrow = function() {
if (this.instance !== CodeMirror) {
console.error('Only CodeMirror supported');
throw new Error('Only CodeMirror supported');
}
};

View File

@ -1,12 +1,12 @@
/**
* Runtime color for updating instance objects
* R3.Color
* @param parent
* @param apiColor R3.API.Color
* @param apiComponent
* @constructor
*/
R3.Color = function(
parent,
apiColor
apiComponent
) {
if (R3.Utils.UndefinedOrNull(parent)) {
@ -14,32 +14,16 @@ R3.Color = function(
}
this.parent = parent;
if (R3.Utils.UndefinedOrNull(apiColor)) {
apiColor = {};
}
this.apiColor = apiColor;
__RUNTIME_COMPONENT_MACRO__;
R3.API.Color.call(
this,
this.apiColor.r,
this.apiColor.g,
this.apiColor.b,
this.apiColor.a
apiComponent.r,
apiComponent.g,
apiComponent.b,
apiComponent.a
);
this.graphics = null;
this.physics = null;
R3.Event.Emit(
R3.Event.GET_RUNTIME,
function(runtime) {
this.graphics = runtime.graphics;
this.physics = runtime.physics;
}.bind(this)
);
this.componentRuntime = R3.Component.GetComponentRuntime(parent);
this.createInstance();
};
@ -52,16 +36,13 @@ R3.Color.prototype.constructor = R3.Color;
*/
R3.Color.prototype.createInstance = function() {
switch (this.componentRuntime) {
case R3.Component.GRAPHICS_RUNTIME :
this.instance = this.graphics.Color(
this.r,
this.g,
this.b,
this.a
);
break;
}
this.instance = this.graphics.Color(
this.r,
this.g,
this.b,
this.a
);
};
/**
@ -69,13 +50,24 @@ R3.Color.prototype.createInstance = function() {
*/
R3.Color.prototype.updateInstance = function(property) {
this.instance.r = this.r;
this.instance.g = this.g;
this.instance.b = this.b;
if (property === 'r') {
this.instance.r = this.r;
return;
}
if (this.parentObject &&
this.parentObject.updateInstance) {
this.parentObject.updateInstance(property);
if (property === 'g') {
this.instance.g = this.g;
return;
}
if (property === 'b') {
this.instance.b = this.b;
return;
}
if (property === 'a') {
this.instance.a = this.a;
return;
}
};

View File

@ -1,71 +1,37 @@
/**
* R3.Controls
* @param apiControls
* @property controlsType
* R3.Controls is an R3.Component
* @param parent
* @param linkedObjects
* @constructor
*/
R3.Controls = function(
apiControls
parent,
linkedObjects
) {
if (R3.Utils.UndefinedOrNull(apiControls)) {
apiControls = {};
if (R3.Utils.UndefinedOrNull(linkedObjects)) {
linkedObjects = {};
}
R3.API.Controls.call(
this,
apiControls.id,
apiControls.name,
apiControls.canvas,
apiControls.parent
);
var linkedObjects = {
canvas : R3.Canvas
};
var delayed = false;
switch (this.controlsType) {
case (R3.API.Controls.CONTROLS_TYPE_EDITOR) :
linkedObjects.raycaster = R3.D3.Raycaster;
linkedObjects.camera = R3.D3.Camera;
delayed = true;
break;
case (R3.API.Controls.CONTROLS_TYPE_FIRST_PERSON) :
linkedObjects.camera = R3.D3.Camera;
delayed = true;
break;
case (R3.API.Controls.CONTROLS_TYPE_ORBIT) :
linkedObjects.camera = R3.D3.Camera;
linkedObjects.target = R3.Component;
delayed = true;
break;
if (this.canvas instanceof R3.API.Component) {
this.canvas = R3.Component.ConstructFromObject(this.canvas);
}
linkedObjects.canvas = R3.Canvas;
R3.Component.call(
this,
linkedObjects,
delayed
parent,
linkedObjects
);
};
R3.Controls.prototype = Object.create(R3.Component.prototype);
R3.Controls.prototype.constructor = R3.Controls;
R3.Controls.D3 = function() {};
R3.Controls.D3.prototype = Object.create(R3.Controls.prototype);
R3.Controls.D3.prototype.constructor = R3.Controls.D3;
/**
* Creates a mesh instance or updates it
*/
R3.Controls.prototype.createInstance = function() {
R3.Component.prototype.createInstance.call(this);
};
/**
* Updates the mesh instance
* R3.Controls.prototype.updateInstance
* @param property
*/
R3.Controls.prototype.updateInstance = function(property) {
@ -76,24 +42,8 @@ R3.Controls.prototype.updateInstance = function(property) {
component: this
}
);
return;
}
R3.Component.prototype.updateInstance.call(this, property);
};
/**
* Converts a R3.Controls to a R3.API.Controls
* @returns {R3.API.Controls}
*/
R3.Controls.prototype.toApiObject = function() {
var apiControls = new R3.API.Controls(
this.id,
this.name,
this.controlsType,
R3.Utils.IdOrNull(this.canvas),
R3.Utils.IdOrNull(this.parent)
);
return apiControls;
};

View File

@ -1,46 +1,35 @@
/**
* Controls Superset - The apiControls properties get moved into the Controls object itself, and then the instance is created
* @param graphics R3.GraphicsRuntime
* @param apiEditorControls
* R3.Controls.D3.Editor is an R3.Controls.D3
* @param parent
* @param apiComponent
* @constructor
*/
R3.Controls.D3.Editor = function(
graphics,
apiEditorControls
parent,
apiComponent
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (R3.Utils.UndefinedOrNull(apiEditorControls)) {
apiEditorControls = {
controlsType : R3.API.Controls.CONTROLS_TYPE_EDITOR
};
}
if (R3.Utils.UndefinedOrNull()) {
apiEditorControls.controlsType = R3.API.Controls.CONTROLS_TYPE_EDITOR;
}
__RUNTIME_COMPONENT_MACRO__;
R3.API.Controls.D3.Editor.call(
this,
apiEditorControls,
apiEditorControls.raycaster,
apiEditorControls.camera
apiComponent,
apiComponent.raycaster
);
if (this.raycaster instanceof R3.D3.API.Raycaster) {
this.raycaster = new R3.D3.Raycaster(
this.graphics,
this.raycaster
);
if (this.raycaster instanceof R3.API.Component) {
this.raycaster = R3.Component.ConstructFromObject(this.raycaster);
}
R3.Controls.call(
this,
apiEditorControls
);
var linkedObjects = {
raycaster : R3.D3.Raycaster
};
R3.Controls.D3.call(
this,
parent,
linkedObjects
)
};
/**
@ -55,28 +44,9 @@ R3.Controls.D3.Editor.prototype.constructor = R3.Controls.D3.Editor;
*/
R3.Controls.D3.Editor.prototype.createInstance = function() {
if (
R3.Utils.UndefinedOrNull(this.camera) ||
R3.Utils.UndefinedOrNull(this.camera.instance)
) {
console.warn('no camera at time of editor-controls create instance');
return;
}
this.instance = this.graphics.EditorControls(this.canvas, this.camera);
if (
R3.Utils.UndefinedOrNull(this.canvas) ||
R3.Utils.UndefinedOrNull(this.canvas.instance)
) {
console.warn('no canvas at time of editor-controls create instance');
return;
}
this.instance = new THREE.EditorControls(
this.camera.instance,
this.canvas.instance
);
R3.Controls.prototype.createInstance.call(this);
R3.Component.prototype.createInstance.call(this);
};
/**
@ -85,32 +55,10 @@ R3.Controls.D3.Editor.prototype.createInstance = function() {
R3.Controls.D3.Editor.prototype.updateInstance = function(property) {
if (
property === 'canvas' ||
property === 'camera'
property === 'raycaster'
) {
if (R3.Utils.UndefinedOrNull(this.instance)) {
this.createInstance();
} else {
this.instance.dispose();
this.createInstance();
}
console.warn('todo : update raycaster');
}
console.warn('an update instance was called on editor controls - which, if not called from within a running system at the right time will affect the order of input event handling and cause system instability');
R3.Controls.prototype.updateInstance.call(this, property);
};
/**
* Converts a R3.Controls.D3.Editor to a R3.D3.API.Mesh
* @returns {R3.API.Controls}
*/
R3.Controls.D3.Editor.prototype.toApiObject = function() {
var apiControls = R3.Controls.prototype.toApiObject.call(this);
apiControls.raycaster = R3.Utils.IdOrNull(this.raycaster);
apiControls.camera = R3.Utils.IdOrNull(this.camera);
return apiControls;
R3.Controls.D3.prototype.updateInstance.call(this, property);
};

View File

@ -1,51 +1,39 @@
/**
* Controls Superset - The apiControls properties get moved into the Controls object itself, and then the instance is created
* @param graphics R3.GraphicsRuntime
* @param apiFirstPersonControls
* R3.Controls.D3.FirstPerson is an R3.Controls.D3
* @param parent
* @param apiComponent
* @constructor
*/
R3.Controls.D3.FirstPerson = function(
graphics,
apiFirstPersonControls
parent,
apiComponent
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (R3.Utils.UndefinedOrNull(apiFirstPersonControls)) {
apiFirstPersonControls = {
controlsType : R3.API.Controls.CONTROLS_TYPE_FIRST_PERSON
};
}
if (R3.Utils.UndefinedOrNull()) {
apiFirstPersonControls.controlsType = R3.API.Controls.CONTROLS_TYPE_FIRST_PERSON;
}
__RUNTIME_COMPONENT_MACRO__;
R3.API.Controls.D3.FirstPerson.call(
this,
apiFirstPersonControls,
apiFirstPersonControls.camera,
apiFirstPersonControls.enabled,
apiFirstPersonControls.movementSpeed,
apiFirstPersonControls.lookSpeed,
apiFirstPersonControls.lookVertical,
apiFirstPersonControls.autoForward,
apiFirstPersonControls.activeLook,
apiFirstPersonControls.heightSpeed,
apiFirstPersonControls.heightCoef,
apiFirstPersonControls.heightMin,
apiFirstPersonControls.heightMax,
apiFirstPersonControls.constrainVertical,
apiFirstPersonControls.verticalMin,
apiFirstPersonControls.verticalMax,
apiFirstPersonControls.autoSpeedFactor
apiComponent,
apiComponent.enabled,
apiComponent.movementSpeed,
apiComponent.lookSpeed,
apiComponent.lookVertical,
apiComponent.autoForward,
apiComponent.activeLook,
apiComponent.heightSpeed,
apiComponent.heightCoef,
apiComponent.heightMin,
apiComponent.heightMax,
apiComponent.constrainVertical,
apiComponent.verticalMin,
apiComponent.verticalMax,
apiComponent.autoSpeedFactor
);
R3.Controls.call(
R3.Controls.D3.call(
this,
apiFirstPersonControls
);
parent
)
};
@ -61,43 +49,26 @@ R3.Controls.D3.FirstPerson.prototype.constructor = R3.Controls.D3.FirstPerson;
*/
R3.Controls.D3.FirstPerson.prototype.createInstance = function() {
if (
R3.Utils.UndefinedOrNull(this.camera) ||
R3.Utils.UndefinedOrNull(this.camera.instance)
) {
console.warn('no camera at time of editor-controls create instance');
return;
}
if (
R3.Utils.UndefinedOrNull(this.canvas) ||
R3.Utils.UndefinedOrNull(this.canvas.instance)
) {
console.warn('no canvas at time of editor-controls create instance');
return;
}
this.instance = new THREE.FirstPersonControls(
this.camera.instance,
this.canvas.instance
this.instance = this.graphics.FirstPersonControls(
this.canvas,
this.camera,
this.enabled,
this.movementSpeed,
this.lookSpeed,
this.lookVertical,
this.autoForward,
this.activeLook,
this.heightSpeed,
this.heightCoef,
this.heightMin,
this.heightMax,
this.constrainVertical,
this.verticalMin,
this.verticalMax,
this.autoSpeedFactor
);
this.instance.enabled = this.enabled;
this.instance.movementSpeed = this.movementSpeed;
this.instance.lookSpeed = this.lookSpeed;
this.instance.lookVertical = this.lookVertical;
this.instance.autoForward = this.autoForward;
this.instance.activeLook = this.activeLook;
this.instance.heightSpeed = this.heightSpeed;
this.instance.heightCoef = this.heightCoef;
this.instance.heightMin = this.heightMin;
this.instance.heightMax = this.heightMax;
this.instance.constrainVertical = this.constrainVertical;
this.instance.verticalMin = this.verticalMin;
this.instance.verticalMax = this.verticalMax;
this.instance.autoSpeedFactor = this.autoSpeedFactor;
R3.Controls.prototype.createInstance.call(this);
R3.Component.prototype.createInstance.call(this);
};
/**
@ -105,18 +76,6 @@ R3.Controls.D3.FirstPerson.prototype.createInstance = function() {
*/
R3.Controls.D3.FirstPerson.prototype.updateInstance = function(property) {
if (
property === 'canvas' ||
property === 'camera'
) {
if (R3.Utils.UndefinedOrNull(this.instance)) {
this.createInstance();
} else {
this.instance.dispose();
this.createInstance();
}
}
if (property === 'enabled') {
this.instance.enabled = this.enabled;
return;
@ -186,35 +145,6 @@ R3.Controls.D3.FirstPerson.prototype.updateInstance = function(property) {
this.instance.autoSpeedFactor = this.autoSpeedFactor;
return;
}
R3.Controls.prototype.updateInstance.call(this, property);
};
/**
* Converts a R3.Controls.D3.FirstPerson to a R3.D3.API.Mesh
* @returns {R3.API.Controls}
*/
R3.Controls.D3.FirstPerson.prototype.toApiObject = function() {
var apiControls = R3.Controls.prototype.toApiObject.call(this);
return new R3.API.Controls.D3.FirstPerson(
apiControls,
R3.Utils.IdOrNull(this.camera),
this.enabled,
this.movementSpeed,
this.lookSpeed,
this.lookVertical,
this.autoForward,
this.activeLook,
this.heightSpeed,
this.heightCoef,
this.heightMin,
this.heightMax,
this.constrainVertical,
this.verticalMin,
this.verticalMax,
this.autoSpeedFactor
);
R3.Controls.D3.prototype.updateInstance.call(this, property);
};

View File

@ -1,59 +1,52 @@
/**
* Controls Superset - The apiControls properties get moved into the Controls object itself, and then the instance is created
* @param graphics R3.GraphicsRuntime
* @param apiOrbitControls
* R3.Controls.D3.Orbit is an R3.Controls.D3
* @param parent
* @param apiComponent
* @constructor
*/
R3.Controls.D3.Orbit = function(
graphics,
apiOrbitControls
parent,
apiComponent
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (R3.Utils.UndefinedOrNull(apiOrbitControls)) {
apiOrbitControls = {
controlsType : R3.API.Controls.CONTROLS_TYPE_ORBIT
};
}
if (R3.Utils.UndefinedOrNull()) {
apiOrbitControls.controlsType = R3.API.Controls.CONTROLS_TYPE_ORBIT;
}
__RUNTIME_COMPONENT_MACRO__;
R3.API.Controls.D3.Orbit.call(
this,
apiOrbitControls,
apiOrbitControls.camera,
apiOrbitControls.target,
apiOrbitControls.enabled,
apiOrbitControls.minPolarAngle,
apiOrbitControls.maxPolarAngle,
apiOrbitControls.enableDamping,
apiOrbitControls.dampingFactor,
apiOrbitControls.enableZoom,
apiOrbitControls.zoomSpeed,
apiOrbitControls.enableRotate,
apiOrbitControls.rotateSpeed,
apiOrbitControls.enablePan,
apiOrbitControls.keyPanSpeed,
apiOrbitControls.autoRotate,
apiOrbitControls.autoRotateSpeed,
apiOrbitControls.enableKeys
apiComponent,
apiComponent.target,
apiComponent.enabled,
apiComponent.minPolarAngle,
apiComponent.maxPolarAngle,
apiComponent.enableDamping,
apiComponent.dampingFactor,
apiComponent.enableZoom,
apiComponent.zoomSpeed,
apiComponent.enableRotate,
apiComponent.rotateSpeed,
apiComponent.enablePan,
apiComponent.keyPanSpeed,
apiComponent.autoRotate,
apiComponent.autoRotateSpeed,
apiComponent.enableKeys
);
R3.Controls.call(
if (this.target instanceof R3.API.Component) {
this.target = R3.Component.ConstructFromObject(this.target);
}
var linkedObjects = {
target : R3.D3.Object
};
R3.Controls.D3.call(
this,
apiOrbitControls
);
parent,
linkedObjects
)
};
/**
* Inheritance
* @type {R3.Controls}
*/
R3.Controls.D3.Orbit.prototype = Object.create(R3.Controls.D3.prototype);
R3.Controls.D3.Orbit.prototype.constructor = R3.Controls.D3.Orbit;
@ -62,47 +55,27 @@ R3.Controls.D3.Orbit.prototype.constructor = R3.Controls.D3.Orbit;
*/
R3.Controls.D3.Orbit.prototype.createInstance = function() {
if (
R3.Utils.UndefinedOrNull(this.camera) ||
R3.Utils.UndefinedOrNull(this.camera.instance)
) {
console.warn('no camera at time of editor-controls create instance');
return;
}
if (
R3.Utils.UndefinedOrNull(this.canvas) ||
R3.Utils.UndefinedOrNull(this.canvas.instance)
) {
console.warn('no canvas at time of editor-controls create instance');
return;
}
this.instance = new THREE.OrbitControls(
this.camera.instance,
this.canvas.instance
this.instance = this.graphics.OrbitControls(
this.canvas,
this.camera,
this.target,
this.enabled,
this.minPolarAngle,
this.maxPolarAngle,
this.enableDamping,
this.dampingFactor,
this.enableZoom,
this.zoomSpeed,
this.enableRotate,
this.rotateSpeed,
this.enablePan,
this.keyPanSpeed,
this.autoRotate,
this.autoRotateSpeed,
this.enableKeys
);
if (this.target && this.target.instance) {
this.instance.target = this.target.instance.position;
}
this.instance.enabled = this.enabled;
this.instance.minPolarAngle = this.minPolarAngle;
this.instance.maxPolarAngle = this.maxPolarAngle;
this.instance.enableDamping = this.enableDamping;
this.instance.dampingFactor = this.dampingFactor;
this.instance.enableZoom = this.enableZoom;
this.instance.zoomSpeed = this.zoomSpeed;
this.instance.enableRotate = this.enableRotate;
this.instance.rotateSpeed = this.rotateSpeed;
this.instance.enablePan = this.enablePan;
this.instance.keyPanSpeed = this.keyPanSpeed;
this.instance.autoRotate = this.autoRotate;
this.instance.autoRotateSpeed = this.autoRotateSpeed;
this.instance.enableKeys = this.enableKeys;
R3.Controls.prototype.createInstance.call(this);
R3.Component.prototype.createInstance.call(this);
};
/**
@ -110,24 +83,12 @@ R3.Controls.D3.Orbit.prototype.createInstance = function() {
*/
R3.Controls.D3.Orbit.prototype.updateInstance = function(property) {
if (
property === 'canvas' ||
property === 'camera'
) {
if (R3.Utils.UndefinedOrNull(this.instance)) {
this.createInstance();
} else {
this.instance.dispose();
this.createInstance();
}
}
if (property === 'target') {
if (this.target && this.target.instance) {
this.instance.target = this.target.instance.position;
} else {
this.instance.target = new THREE.Vector3();
this.instance.target = new this.graphics.Vector3();
}
return;
}
@ -201,35 +162,6 @@ R3.Controls.D3.Orbit.prototype.updateInstance = function(property) {
this.instance.enableKeys = this.enableKeys;
return;
}
R3.Controls.prototype.updateInstance.call(this, property);
};
/**
* Converts a R3.Controls.D3.Orbit to a R3.D3.API.Mesh
* @returns {R3.API.Controls}
*/
R3.Controls.D3.Orbit.prototype.toApiObject = function() {
var apiControls = R3.Controls.prototype.toApiObject.call(this);
return new R3.API.Controls.D3.Orbit(
apiControls,
R3.Utils.IdOrNull(this.camera),
R3.Utils.IdOrNull(this.target),
this.enabled,
this.minPolarAngle,
this.maxPolarAngle,
this.enableDamping,
this.dampingFactor,
this.enableZoom,
this.zoomSpeed,
this.enableRotate,
this.rotateSpeed,
this.enablePan,
this.keyPanSpeed,
this.autoRotate,
this.autoRotateSpeed,
this.enableKeys
);
R3.Controls.D3.prototype.updateInstance.call(this, property);
};

37
src/r3-controls-d3.js Normal file
View File

@ -0,0 +1,37 @@
/**
* R3.Controls.D3 is an R3.Controls
* @param parent
* @param linkedObjects
* @constructor
*/
R3.Controls.D3 = function(
parent,
linkedObjects
) {
if (R3.Utils.UndefinedOrNull(linkedObjects)) {
linkedObjects = {};
}
linkedObjects.camera = R3.D3.Camera;
R3.Controls.call(
this,
parent,
linkedObjects
);
};
R3.Controls.D3.prototype = Object.create(R3.Controls.prototype);
R3.Controls.D3.prototype.constructor = R3.Controls.D3;
R3.Controls.D3.prototype.updateInstance = function(property) {
if (property === 'camera') {
console.warn('update camera instance update');
return;
}
R3.Controls.prototype.updateInstance.call(this, property);
};

View File

@ -1,26 +1,24 @@
/**
* Keyboard Controls
* @param apiKeyboardControls R3.API.Controls
* R3.Controls.Keyboard is an R3.Controls
* @param parent
* @param apiComponent
* @constructor
*/
R3.Controls.Keyboard = function(
apiKeyboardControls
parent,
apiComponent
) {
if (R3.Utils.UndefinedOrNull(apiKeyboardControls)) {
apiKeyboardControls = {
controlsType : R3.API.Controls.CONTROLS_TYPE_KEYBOARD
};
}
__RUNTIME_COMPONENT_MACRO__;
R3.API.Controls.Keyboard.call(
this,
apiKeyboardControls
apiComponent
);
R3.Controls.call(
this,
apiKeyboardControls
parent
);
};
@ -36,11 +34,8 @@ R3.Controls.Keyboard.prototype.constructor = R3.Controls.Keyboard;
* @returns
*/
R3.Controls.Keyboard.prototype.createInstance = function() {
/**
* Set instance to true to indicate no dependencies to other components
*/
this.instance = true;
R3.Controls.prototype.createInstance.call(this);
R3.Component.prototype.createInstance.call(this);
};
/**
@ -49,31 +44,3 @@ R3.Controls.Keyboard.prototype.createInstance = function() {
R3.Controls.Keyboard.prototype.updateInstance = function(property) {
R3.Controls.prototype.updateInstance.call(this, property);
};
/**
* Converts a R3.Controls.Keyboard to a R3.API.Controls
* @returns {R3.API.Controls}
*/
R3.Controls.Keyboard.prototype.toApiObject = function() {
var apiControls = R3.Controls.prototype.toApiObject.call(this);
/**
* add other properties here as this component develops...
*/
return apiControls;
};
/**
* Construct an Keyboard Controls object from data
* @param objectControls
* @returns {R3.Controls.Keyboard}
* @constructor
*/
R3.Controls.Keyboard.FromObject = function(objectControls) {
var apiKeyboardControls = R3.API.Controls.Keyboard.FromObject(objectControls);
return new R3.Controls.Keyboard(
apiKeyboardControls
);
};

View File

@ -1,26 +1,24 @@
/**
* Mouse Controls
* @param apiMouseControls R3.API.Controls
* R3.Controls.Mouse
* @param parent
* @param apiComponent
* @constructor
*/
R3.Controls.Mouse = function(
apiMouseControls
parent,
apiComponent
) {
if (R3.Utils.UndefinedOrNull(apiMouseControls)) {
apiMouseControls = {
controlsType : R3.API.Controls.CONTROLS_TYPE_MOUSE
};
}
__RUNTIME_COMPONENT_MACRO__;
R3.API.Controls.Mouse.call(
this,
apiMouseControls
apiComponent
);
R3.Controls.call(
this,
apiMouseControls
parent
);
};
@ -36,11 +34,8 @@ R3.Controls.Mouse.prototype.constructor = R3.Controls.Mouse;
* @returns
*/
R3.Controls.Mouse.prototype.createInstance = function() {
/**
* Set instance to true to indicate no dependencies to other components
*/
this.instance = true;
R3.Controls.prototype.createInstance.call(this);
R3.Component.prototype.createInstance.call(this);
};
/**
@ -49,31 +44,3 @@ R3.Controls.Mouse.prototype.createInstance = function() {
R3.Controls.Mouse.prototype.updateInstance = function(property) {
R3.Controls.prototype.updateInstance.call(this, property);
};
/**
* Converts a R3.Controls.Mouse to a R3.API.Controls
* @returns {R3.API.Controls}
*/
R3.Controls.Mouse.prototype.toApiObject = function() {
var apiControls = R3.Controls.prototype.toApiObject.call(this);
/**
* add other properties here as this component develops...
*/
return apiControls;
};
/**
* Construct an Mouse Controls object from data
* @param objectControls
* @returns {R3.Controls.Mouse}
* @constructor
*/
R3.Controls.Mouse.FromObject = function(objectControls) {
var apiMouseControls = R3.API.Controls.Mouse.FromObject(objectControls);
return new R3.Controls.Mouse(
apiMouseControls
);
};

View File

@ -1,28 +1,27 @@
/**
* Touch Controls
* @constructor
* @param apiTouchControls
* @param parent
* @param apiComponent
*/
R3.Controls.Touch = function(
apiTouchControls
parent,
apiComponent
) {
if (R3.Utils.UndefinedOrNull(apiTouchControls)) {
apiTouchControls = {
controlsType : R3.API.Controls.CONTROLS_TYPE_TOUCH
};
}
__RUNTIME_COMPONENT_MACRO__;
R3.API.Controls.Touch.call(
this,
apiTouchControls,
apiTouchControls.sensitivity
apiComponent,
apiComponent.sensitivity
);
R3.Controls.call(
this,
apiTouchControls
parent
);
};
/**
@ -37,11 +36,8 @@ R3.Controls.Touch.prototype.constructor = R3.Controls.Touch;
* @returns
*/
R3.Controls.Touch.prototype.createInstance = function() {
/**
* Set instance to true to indicate no dependencies to other components
*/
this.instance = true;
R3.Controls.prototype.createInstance.call(this);
R3.Component.prototype.createInstance.call(this);
};
/**
@ -50,33 +46,3 @@ R3.Controls.Touch.prototype.createInstance = function() {
R3.Controls.Touch.prototype.updateInstance = function(property) {
R3.Controls.prototype.updateInstance.call(this, property);
};
/**
* Converts a R3.Controls.Touch to a R3.API.Controls
* @returns {R3.API.Controls}
*/
R3.Controls.Touch.prototype.toApiObject = function() {
var apiControls = R3.Controls.prototype.toApiObject.call(this);
apiControls.sensitivity = this.sensitivity;
/**
* add other properties here as this component develops...
*/
return apiControls;
};
/**
* Construct an Touch Controls object from data
* @param objectControls
* @returns {R3.Controls.Touch}
* @constructor
*/
R3.Controls.Touch.FromObject = function(objectControls) {
var apiTouchControls = R3.API.Controls.Touch.FromObject(objectControls);
return new R3.Controls.Touch(apiTouchControls);
};

View File

@ -1,43 +1,53 @@
/**
* R3.Curve
* @param graphics R3.GraphicsRuntime
* @param apiCurve R3.API.Curve
* @property curveType
* @param parent
* @param apiComponent
* @param linkedObjects
* @constructor
*/
R3.Curve = function(
graphics,
apiCurve
parent,
apiComponent,
linkedObjects
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (R3.Utils.UndefinedOrNull(linkedObjects)) {
/**
* This class behaves in such a way that we can create instances from it - we define the runtime and construct
* the api object and upgrade its properties (if any) to runtime
*/
__RUNTIME_COMPONENT_MACRO__;
R3.API.Curve.call(
this,
apiComponent,
apiComponent.arcLenghDivisions
);
R3.Component.call(
this,
parent
);
} else {
/**
* This class was inherited and Component constructor will call the child class createInstance()
* Add any more linking information to the linkedObjects object here
*/
R3.Component.call(
this,
parent,
linkedObjects
);
if (R3.Utils.UndefinedOrNull(apiCurve)) {
apiCurve = {};
}
R3.API.Curve.call(
this,
apiCurve.id,
apiCurve.name,
apiCurve.curveType,
apiCurve.parent,
apiCurve.arcLenghDivisions
);
var linkedObjects = {};
switch (this.curveType) {
case R3.API.Curve.CURVE_TYPE_PATH :
linkedObjects.curves = [R3.Curve];
break;
}
R3.Component.call(
this,
linkedObjects
);
};
R3.Curve.prototype = Object.create(R3.Component.prototype);
@ -47,14 +57,7 @@ R3.Curve.prototype.constructor = R3.Curve;
* Create Instance
*/
R3.Curve.prototype.createInstance = function() {
if (R3.Utils.UndefinedOrNull(this.instance)) {
console.warn('you should not instantiate this curve object directly');
this.instance = new THREE.Curve();
}
this.instance.arcLenghDivisions = this.arcLenghDivisions;
this.instance = this.graphics.Curve(this.arcLenghDivisions);
R3.Component.prototype.createInstance.call(this);
};
@ -65,23 +68,8 @@ R3.Curve.prototype.updateInstance = function(property) {
if (property === 'arcLenghDivisions') {
this.instance.arcLenghDivisions = this.arcLenghDivisions;
return;
}
R3.Component.prototype.updateInstance.call(this, property);
};
/**
* Converts a R3.Curve to a new R3.API.Curve
* @returns {R3.API.Curve}
*/
R3.Curve.prototype.toApiObject = function() {
return new R3.API.Curve(
this.id,
this.name,
this.curveType,
R3.Utils.IdOrNull(this.parent),
this.arcLenghDivisions
);
};

View File

@ -1,47 +1,70 @@
/**
* R3.Curve.Path
* @param graphics R3.GraphicsRuntime
* @param apiCurvePath
* @constructor
* @param parent
* @param apiComponent
* @param linkedObjects
*/
R3.Curve.Path = function(
graphics,
apiCurvePath
parent,
apiComponent,
linkedObjects
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (R3.Utils.UndefinedOrNull(linkedObjects)) {
if (R3.Utils.UndefinedOrNull(apiCurvePath)) {
apiCurvePath = {
curveType : R3.API.Curve.CURVE_TYPE_PATH
/**
* This class behaves in such a way that we can create instances from it - we define the runtime and construct
* the api object and upgrade its properties to runtime
*/
__RUNTIME_COMPONENT_MACRO__;
R3.API.Curve.Path.call(
this,
apiComponent,
apiComponent.curves,
apiComponent.autoClose
);
this.curves = this.curves.reduce(
function(result, curve) {
if (curve instanceof R3.API.Component) {
curve = R3.Component.ConstructFromObject(curve);
}
result.push(curve);
return result;
},
[]
);
linkedObjects = {
curves : [R3.Curve]
};
} else {
/**
* This class was inherited and Component constructor will call the child class createInstance()
* Add any more linking information to the linkedObjects object here - and pass up the inheritence chain
* so more linking information can be attached
*/
linkedObjects.curves = [R3.Curve];
}
R3.API.Curve.Path.call(
this,
apiCurvePath,
apiCurvePath.curves,
apiCurvePath.autoClose
);
this.curves = this.curves.map(
function(curve) {
if (curve instanceof R3.API.Curve) {
return new R3.Curve(
this.graphics,
curve
);
}
}.bind(this)
);
/**
* Now we call the parent class but with linkedObjects - indicating that its being called from a child class
* and should not do any runtime instantiation
*/
R3.Curve.call(
this,
this.graphics,
this
);
parent,
apiComponent,
linkedObjects
)
};
R3.Curve.Path.prototype = Object.create(R3.Curve.prototype);
@ -53,20 +76,9 @@ R3.Curve.Path.prototype.constructor = R3.Curve.Path;
*/
R3.Curve.Path.prototype.createInstance = function() {
if (R3.Utils.UndefinedOrNull(this.instance)) {
console.warn('you should not instantiate this curve object directly');
this.instance = new THREE.CurvePath();
}
this.instance = this.graphics.CurvePath(this.curves, this.autoClose);
this.instance.curves = this.curves.map(
function(curve) {
return curve.instance;
}
);
this.instance.autoClose = this.autoClose;
R3.Curve.prototype.createInstance.call(this);
R3.Component.prototype.createInstance.call(this);
};
/**
@ -86,24 +98,3 @@ R3.Curve.Path.prototype.updateInstance = function(property) {
R3.Curve.prototype.updateInstance.call(this, property);
};
/**
* Converts a R3.Curve to a R3.API.Curve
* @returns {R3.API.Curve}
*/
R3.Curve.Path.prototype.toApiObject = function() {
var apiCurve = R3.Curve.prototype.toApiObject.call(this);
var apiCurvePath = new R3.API.Curve.Path(
apiCurve,
this.curves.map(
function(curve) {
return R3.Utils.IdOrNull(curve);
}
),
this.autoClose
);
return apiCurvePath;
};

View File

@ -1,43 +1,73 @@
/**
* R3.Curve.Path.D2
* @param graphics R3.GraphicsRuntime
* @param apiCurvePath
* @param parent
* @param apiComponent
* @param linkedObjects
* @constructor
*/
R3.Curve.Path.D2 = function(
graphics,
apiCurvePath
parent,
apiComponent,
linkedObjects
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (R3.Utils.UndefinedOrNull(apiCurvePath)) {
apiCurvePath = {
curveType : R3.API.Curve.CURVE_TYPE_PATH_2D
};
if (R3.Utils.UndefinedOrNull(linkedObjects)) {
/**
* This class behaves in such a way that we can create instances from it - we define the runtime and construct
* the api object and upgrade its properties to runtime
*/
__RUNTIME_COMPONENT_MACRO__;
R3.API.Curve.Path.D2.call(
this,
apiComponent,
apiComponent.points
);
} else {
/**
* This class was inherited and Component constructor will call the child class createInstance()
* Add any more linking information to the linkedObjects object here -
* Points aren't components so they don't get added to linkedObjects
* @type {R3.Vector2}
*/
}
R3.API.Curve.Path.D2.call(
this,
apiCurvePath,
apiCurvePath.points
);
this.points = this.points.reduce(
function(result, point) {
this.points = this.points.map(
function(point) {
return new R3.Vector2(
this.graphics,
/**
* Points aren't components so they don't get added to linkedObjects
* @type {R3.Vector2}
*/
point = new R3.Vector2(
this,
point
);
}.bind(this)
result.push(point);
return result;
},
[]
);
/**
* Now we call the parent class but with linkedObjects - indicating that its being called from a child class
* and should not do any runtime instantiation
*/
R3.Curve.Path.call(
this,
this.graphics,
this
parent,
apiComponent,
linkedObjects
);
};
@ -50,17 +80,9 @@ R3.Curve.Path.D2.prototype.constructor = R3.Curve.Path.D2;
*/
R3.Curve.Path.D2.prototype.createInstance = function() {
if (R3.Utils.UndefinedOrNull(this.instance)) {
this.instance = new THREE.Path(
this.points.map(
function(point) {
return point.instance;
}
)
);
}
this.instance = this.graphics.Path(this.points);
R3.Curve.Path.prototype.createInstance.call(this);
R3.Component.prototype.createInstance.call(this);
};
/**
@ -70,32 +92,7 @@ R3.Curve.Path.D2.prototype.updateInstance = function(property) {
if (property === 'points') {
console.warn('todo: update points (and test it)');
this.instance.points = this.points.map(
function(point) {
return point.instance;
}
);
return;
}
R3.Curve.Path.prototype.updateInstance.call(this, property);
};
/**
* Converts a R3.Curve to a R3.API.Curve
* @returns {R3.API.Curve}
*/
R3.Curve.Path.D2.prototype.toApiObject = function() {
var apiCurvePath = R3.Curve.Path.prototype.toApiObject.call(this);
return new R3.API.Curve.Path.D2(
apiCurvePath,
this.points.map(
function(point) {
return point.toApiObject();
}
)
);
};

View File

@ -1,34 +1,49 @@
/**
* R3.Curve.Path.D2
* @param graphics R3.GraphicsRuntime
* @param apiCurvePathD2
* R3.Curve.Path.D2.Shape
* @param parent
* @param apiComponent
* @param linkedObjects
* @constructor
*/
R3.Curve.Path.D2.Shape = function(
graphics,
apiCurvePathD2
parent,
apiComponent,
linkedObjects
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (R3.Utils.UndefinedOrNull(linkedObjects)) {
/**
* This class behaves in such a way that we can create instances from it - we define the runtime and construct
* the api object and upgrade its properties to runtime
*/
__RUNTIME_COMPONENT_MACRO__;
R3.API.Curve.Path.D2.Shape.call(
this,
apiComponent
);
} else {
/**
* This class was inherited and Component constructor will call the child class createInstance()
* Add any more linking information to the linkedObjects object here
*/
if (R3.Utils.UndefinedOrNull(apiCurvePathD2)) {
apiCurvePathD2 = {
curveType : R3.API.Curve.CURVE_TYPE_PATH_2D_SHAPE
};
}
R3.API.Curve.Path.D2.call(
this,
apiCurvePathD2,
apiCurvePathD2.points
);
/**
* Now we call the parent class but with linkedObjects - indicating that its being called from a child class
* and should not do any runtime instantiation
*/
R3.Curve.Path.D2.call(
this,
this.graphics,
this
);
parent,
apiComponent,
linkedObjects
)
};
@ -41,15 +56,9 @@ R3.Curve.Path.D2.Shape.prototype.constructor = R3.Curve.Path.D2.Shape;
*/
R3.Curve.Path.D2.Shape.prototype.createInstance = function() {
this.instance = new THREE.Shape(
this.points.map(
function(point) {
return point.instance;
}
)
);
this.instance = this.graphics.Shape(this.points);
R3.Curve.Path.D2.prototype.createInstance.call(this);
R3.Component.prototype.createInstance.call(this);
};
/**
@ -58,17 +67,3 @@ R3.Curve.Path.D2.Shape.prototype.createInstance = function() {
R3.Curve.Path.D2.Shape.prototype.updateInstance = function(property) {
R3.Curve.Path.D2.prototype.updateInstance.call(this, property);
};
/**
* Converts a R3.Curve to a R3.API.Curve
* @returns {R3.API.Curve}
*/
R3.Curve.Path.D2.Shape.prototype.toApiObject = function() {
var apiCurvePathD2 = R3.Curve.Path.D2.prototype.toApiObject.call(this);
return new R3.API.Curve.Path.D2.Shape(
apiCurvePathD2
);
};

View File

@ -1,28 +1,29 @@
/**
* Creates a CustomCode object
* @param apiCustomCode R3.API.CustomCode
* R3.CustomCode
* @param parent
* @param apiComponent
* @constructor
*/
R3.CustomCode = function(
apiCustomCode
parent,
apiComponent
) {
if (R3.Utils.UndefinedOrNull(apiCustomCode)) {
apiCustomCode = {};
}
__RUNTIME_COMPONENT_MACRO__;
R3.API.CustomCode.call(
this,
apiCustomCode.id,
apiCustomCode.name,
apiCustomCode.eventId,
apiCustomCode.code,
apiCustomCode.parent
apiComponent,
apiComponent.eventId,
apiComponent.code,
);
this.editor = null;
R3.Component.call(this);
R3.Component.call(
this,
parent
);
};
R3.CustomCode.prototype = Object.create(R3.Component.prototype);
@ -31,7 +32,9 @@ R3.CustomCode.prototype.constructor = R3.CustomCode;
R3.CustomCode.prototype.createInstance = function() {
try {
this.instance = new Function('data', this.code).bind(this);
this.instance = new Function('data', this.code).bind(this);
} catch (error) {
/**
* Set the instance to true here to indicate that even though the compilation failed, the instance will be fine and
@ -93,33 +96,8 @@ R3.CustomCode.prototype.updateInstance = function(property) {
R3.Component.prototype.updateInstance.call(this, property);
};
/**
* Converts a R3.CustomCode to a new R3.API.CustomCode
* @returns {R3.API.CustomCode}
*/
R3.CustomCode.prototype.toApiObject = function() {
return new R3.API.CustomCode(
this.id,
this.name,
this.eventId,
this.code,
R3.Utils.IdOrNull(this.parent)
);
};
R3.CustomCode.prototype.launchEditor = function(){
R3.Event.Emit(
R3.Event.GET_RUNTIME,
null,
function(runtime) {
this.coder = runtime.coder;
this.coder.isNotCodeMirrorThrow();
}.bind(this)
);
if (this instanceof R3.D3.Shader.Vertex) {
this.editor = this.coder.instance(
document.body,

View File

@ -21,7 +21,7 @@ R3.D3.API.Object = function(
lookAt
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(useQuaternion)) {
useQuaternion = true;

View File

@ -23,7 +23,7 @@ R3.D3.API.Animation = function(
applyToMeshWhenDone
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(rotationSpeed)) {
rotationSpeed = 0;

View File

@ -4,8 +4,7 @@
* @param path
* @param loop
* @param volume
* @param camera
* @param overplay
* @param cameraIndex
* @param paused
* @constructor
*/
@ -14,12 +13,11 @@ R3.D3.API.Audio = function(
path,
loop,
volume,
camera,
overplay,
cameraIndex,
paused
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(path)) {
path = '';
@ -36,15 +34,10 @@ R3.D3.API.Audio = function(
}
this.volume = volume;
if (R3.Utils.UndefinedOrNull(camera)) {
camera = null;
if (R3.Utils.UndefinedOrNull(cameraIndex)) {
cameraIndex = R3.API.Project.CAMERA_INDEX_RUN;
}
this.camera = camera;
if (R3.Utils.UndefinedOrNull(overplay)) {
overplay = false;
}
this.overplay = overplay;
this.cameraIndex = cameraIndex;
if (R3.Utils.UndefinedOrNull(paused)) {
paused = false;

View File

@ -1,13 +1,28 @@
/**
* BoneWeight object - associates a vertex to a bone with some weight
* @param boneIndex int
* @param weight float
* R3.D3.API.BoneWeight
* @param apiComponent
* @param boneIndex
* @param weight
* @constructor
*/
R3.D3.API.BoneWeight = function(
apiComponent,
boneIndex,
weight
) {
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(boneIndex)) {
boneIndex = 0;
}
this.boneIndex = boneIndex;
if (R3.Utils.UndefinedOrNull(weight)) {
weight = 0;
}
this.weight = weight;
};
R3.D3.API.BoneWeight.prototype = Object.create(R3.API.Component.prototype);
R3.D3.API.BoneWeight.prototype.constructor = R3.D3.API.BoneWeight;

View File

@ -9,7 +9,7 @@ R3.D3.API.Broadphase = function(
broadphaseType
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(broadphaseType)) {
broadphaseType = R3.D3.Broadphase.BROADPHASE_TYPE_NAIVE;

View File

@ -45,7 +45,7 @@ R3.D3.API.Camera.Cube = function(
this.cubeResolution = cubeResolution;
if (R3.Utils.UndefinedOrNull(renderTarget)) {
renderTarget = null;
renderTarget = new R3.D3.API.RenderTarget.Cube();
}
this.renderTarget = renderTarget;

View File

@ -15,7 +15,7 @@ R3.D3.API.Composer = function(
passes
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(autoUpdateSize)) {
autoUpdateSize = true;

View File

@ -14,7 +14,7 @@ R3.D3.API.Effect = function(
height
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(width)) {
width = 512;

View File

@ -27,7 +27,7 @@ R3.D3.API.Face = function(
selected
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(v0index)) {
v0index = -1;

View File

@ -17,7 +17,7 @@ R3.D3.API.Fog = function(
density
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(exponential)) {
exponential = false;

View File

@ -9,7 +9,7 @@ R3.D3.API.Font = function(
path
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(path)) {
path = '';

View File

@ -21,7 +21,7 @@ R3.D3.API.FrictionContactMaterial = function(
frictionEquationRelaxation
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(materials)) {
materials = [];

View File

@ -11,7 +11,7 @@ R3.D3.API.FrictionMaterial = function(
restitution
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(friction)) {
friction = -1;

View File

@ -15,7 +15,7 @@ R3.D3.API.Geometry = function(
vertices
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(boundingBox)) {
boundingBox = new R3.API.Box3();

View File

@ -19,7 +19,7 @@ R3.D3.API.Geometry.Buffer.Box = function(
depthSegments
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(width)) {
width = 1;

View File

@ -15,7 +15,7 @@ R3.D3.API.Geometry.Buffer.Circle = function(
thetaLength
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(radius)) {
radius = 1;

View File

@ -21,7 +21,7 @@ R3.D3.API.Geometry.Buffer.Cone = function(
thetaLength
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(radius)) {
radius = 1;

View File

@ -23,7 +23,7 @@ R3.D3.API.Geometry.Buffer.Cylinder = function(
thetaLength
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(radiusTop)) {
radiusTop = 1;

View File

@ -11,7 +11,7 @@ R3.D3.API.Geometry.Buffer.Dodecahedron = function(
detail
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(radius)) {
radius = 1;

View File

@ -29,7 +29,7 @@ R3.D3.API.Geometry.Buffer.Extrude = function(
UVGenerator
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(shapes)) {
shapes = [];

View File

@ -11,7 +11,7 @@ R3.D3.API.Geometry.Buffer.Icosahedron = function(
detail
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(radius)) {
radius = 1;

View File

@ -9,7 +9,7 @@ R3.D3.API.Geometry.Buffer.Instanced = function(
maxInstancedCount
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(maxInstancedCount)) {
maxInstancedCount = null;

View File

@ -15,7 +15,7 @@ R3.D3.API.Geometry.Buffer.Lathe = function(
phiLength
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(points)) {
points = [];

View File

@ -11,7 +11,7 @@ R3.D3.API.Geometry.Buffer.Octahedron = function(
detail
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(radius)) {
radius = 1;

View File

@ -13,7 +13,7 @@ R3.D3.API.Geometry.Buffer.Parametric = function(
stacks
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(generatorFn)) {
generatorFn = '';

View File

@ -15,7 +15,7 @@ R3.D3.API.Geometry.Buffer.Plane = function(
heightSegments
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(width)) {
width = 1;

View File

@ -15,7 +15,7 @@ R3.D3.API.Geometry.Buffer.Polyhedron = function(
detail
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(vertices)) {
vertices = [];

View File

@ -19,7 +19,7 @@ R3.D3.API.Geometry.Buffer.Ring = function(
thetaLength
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(innerRadius)) {
innerRadius = 0.5;

View File

@ -11,7 +11,7 @@ R3.D3.API.Geometry.Buffer.Shape = function(
curveSegments
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(shapes)) {
shapes = [];

View File

@ -21,7 +21,7 @@ R3.D3.API.Geometry.Buffer.Sphere = function(
thetaLength
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(radius)) {
radius = 1;

View File

@ -11,7 +11,7 @@ R3.D3.API.Geometry.Buffer.Tetrahedron = function(
detail
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(radius)) {
radius = 1;

View File

@ -25,7 +25,7 @@ R3.D3.API.Geometry.Buffer.Text = function(
bevelSegments
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(text)) {
text = '-=<yb4f310';

View File

@ -19,7 +19,7 @@ R3.D3.API.Geometry.Buffer.TorusKnot = function(
q
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(radius)) {
radius = 1;

View File

@ -17,7 +17,7 @@ R3.D3.API.Geometry.Buffer.Torus = function(
arc
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(radius)) {
radius = 1;

View File

@ -17,7 +17,7 @@ R3.D3.API.Geometry.Buffer.Tube = function(
closed
) {
__API_GEOMETRY_BUFFER_MACRO__
__API_GEOMETRY_BUFFER_MACRO__;
if (R3.Utils.UndefinedOrNull(path)) {
path = null;

View File

@ -19,7 +19,7 @@ R3.D3.API.Geometry.Normal.Box = function(
depthSegments
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(width)) {
width = 1;

View File

@ -15,7 +15,7 @@ R3.D3.API.Geometry.Normal.Circle = function(
thetaLength
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(radius)) {
radius = 1;

View File

@ -21,7 +21,7 @@ R3.D3.API.Geometry.Normal.Cone = function(
thetaLength
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(radius)) {
radius = 1;

View File

@ -23,7 +23,7 @@ R3.D3.API.Geometry.Normal.Cylinder = function(
thetaLength
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(radiusTop)) {
radiusTop = 1;

View File

@ -11,7 +11,7 @@ R3.D3.API.Geometry.Normal.Dodecahedron = function(
detail
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(radius)) {
radius = 1;

View File

@ -11,7 +11,7 @@ R3.D3.API.Geometry.Normal.Edges = function(
thresholdAngle
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(geometry)) {
geometry = null;

View File

@ -29,7 +29,7 @@ R3.D3.API.Geometry.Normal.Extrude = function(
UVGenerator
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(shapes)) {
shapes = [];

View File

@ -11,7 +11,7 @@ R3.D3.API.Geometry.Normal.Icosahedron = function(
detail
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(radius)) {
radius = 1;

View File

@ -15,7 +15,7 @@ R3.D3.API.Geometry.Normal.Lathe = function(
phiLength
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(points)) {
points = [];

View File

@ -11,7 +11,7 @@ R3.D3.API.Geometry.Normal.Octahedron = function(
detail
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(radius)) {
radius = 1;

View File

@ -13,7 +13,7 @@ R3.D3.API.Geometry.Normal.Parametric = function(
stacks
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(generatorFn)) {
generatorFn = '';

View File

@ -15,7 +15,7 @@ R3.D3.API.Geometry.Normal.Plane = function(
heightSegments
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(width)) {
width = 1;

View File

@ -15,7 +15,7 @@ R3.D3.API.Geometry.Normal.Polyhedron = function(
detail
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(vertices)) {
vertices = [];

View File

@ -19,7 +19,7 @@ R3.D3.API.Geometry.Normal.Ring = function(
thetaLength
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(innerRadius)) {
innerRadius = 0.5;

View File

@ -11,7 +11,7 @@ R3.D3.API.Geometry.Normal.Shape = function(
curveSegments
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(shapes)) {
shapes = [];

View File

@ -21,7 +21,7 @@ R3.D3.API.Geometry.Normal.Sphere = function(
thetaLength
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(radius)) {
radius = 1;

View File

@ -11,7 +11,7 @@ R3.D3.API.Geometry.Normal.Tetrahedron = function(
detail
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(radius)) {
radius = 1;

View File

@ -25,7 +25,7 @@ R3.D3.API.Geometry.Normal.Text = function(
bevelSegments
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(text)) {
text = '-=<yb4f310';

View File

@ -19,7 +19,7 @@ R3.D3.API.Geometry.Normal.TorusKnot = function(
q
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(radius)) {
radius = 1;

View File

@ -17,7 +17,7 @@ R3.D3.API.Geometry.Normal.Torus = function(
arc
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(radius)) {
radius = 1;

View File

@ -17,7 +17,7 @@ R3.D3.API.Geometry.Normal.Tube = function(
closed
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(path)) {
path = null;

View File

@ -9,7 +9,7 @@ R3.D3.API.Geometry.Normal.Wireframe = function(
geometry
) {
__API_GEOMETRY_NORMAL_MACRO__
__API_GEOMETRY_NORMAL_MACRO__;
if (R3.Utils.UndefinedOrNull(geometry)) {
geometry = null;

View File

@ -11,7 +11,7 @@ R3.D3.API.Light = function(
intensity
) {
__API_COMPONENT_MACRO__
__API_COMPONENT_MACRO__;
if (R3.Utils.UndefinedOrNull(color)) {
color = new R3.API.Color(this, 1,1,1);

Some files were not shown because too many files have changed in this diff Show More