From b28b1bc99b9f15e0df0c4710dacd18be1b7c23c4 Mon Sep 17 00:00:00 2001 From: cybafelo Date: Thu, 25 Jul 2019 22:22:32 +0200 Subject: [PATCH] restructuring --- gulpfile.js | 32 +- src/r3-a-2-utils.js | 19 +- ...a-4-component-a.js => r3-a-4-component.js} | 245 +++++++++-- src/r3-api-clock.js | 2 +- src/r3-api-controls-0.js | 2 +- src/{r3-api-curve-a.js => r3-api-curve-0.js} | 2 +- src/r3-api-custom-code.js | 2 +- src/r3-api-dom-element.js | 2 +- src/r3-api-draw-range.js | 2 +- src/r3-api-entity-manager.js | 2 +- src/r3-api-entity.js | 2 +- src/r3-api-group.js | 2 +- src/r3-api-gui.js | 2 +- src/r3-api-image.js | 2 +- src/r3-api-mouse.js | 2 +- src/r3-api-plane.js | 2 +- src/r3-api-project.js | 9 +- src/r3-api-renderer-a.js | 2 +- src/r3-api-server.js | 2 +- src/r3-api-socket-0.js | 2 +- src/r3-api-sphere.js | 2 +- src/r3-api-stats.js | 2 +- src/r3-api-user.js | 2 +- src/r3-api-video.js | 2 +- src/r3-box3.js | 55 +-- src/r3-canvas.js | 85 ++-- src/r3-clock.js | 71 +-- src/r3-coder-runtime.js | 60 --- src/r3-color.js | 72 ++-- src/r3-controls-0.js | 82 +--- src/r3-controls-d3-editor.js | 98 +---- src/r3-controls-d3-first-person.js | 158 ++----- src/r3-controls-d3-orbit.js | 180 +++----- src/r3-controls-d3.js | 37 ++ src/r3-controls-keyboard.js | 51 +-- src/r3-controls-mouse.js | 51 +-- src/r3-controls-touch.js | 54 +-- src/r3-curve-a.js | 92 ++-- src/r3-curve-path-a.js | 121 +++--- src/r3-curve-path-d2-a.js | 111 +++-- src/r3-curve-path-d2-shape.js | 79 ++-- src/r3-custom-code.js | 54 +-- ...-api-a-object.js => r3-d3-api-0-object.js} | 2 +- src/r3-d3-api-animation.js | 2 +- src/r3-d3-api-audio.js | 19 +- src/r3-d3-api-bone-weight.js | 21 +- src/r3-d3-api-broadphase.js | 2 +- src/r3-d3-api-camera-cube.js | 2 +- src/r3-d3-api-composer.js | 2 +- src/r3-d3-api-effect-a.js | 2 +- src/r3-d3-api-face.js | 2 +- src/r3-d3-api-fog.js | 2 +- src/r3-d3-api-font.js | 2 +- src/r3-d3-api-friction-contact-material.js | 2 +- src/r3-d3-api-friction-material.js | 2 +- src/r3-d3-api-geometry-a.js | 2 +- src/r3-d3-api-geometry-buffer-box.js | 2 +- src/r3-d3-api-geometry-buffer-circle.js | 2 +- src/r3-d3-api-geometry-buffer-cone.js | 2 +- src/r3-d3-api-geometry-buffer-cylinder.js | 2 +- src/r3-d3-api-geometry-buffer-dodecahedron.js | 2 +- src/r3-d3-api-geometry-buffer-extrude.js | 2 +- src/r3-d3-api-geometry-buffer-icosahedron.js | 2 +- src/r3-d3-api-geometry-buffer-instanced.js | 2 +- src/r3-d3-api-geometry-buffer-lathe.js | 2 +- src/r3-d3-api-geometry-buffer-octahedron.js | 2 +- src/r3-d3-api-geometry-buffer-parametric.js | 2 +- src/r3-d3-api-geometry-buffer-plane.js | 2 +- src/r3-d3-api-geometry-buffer-polyhedron.js | 2 +- src/r3-d3-api-geometry-buffer-ring.js | 2 +- src/r3-d3-api-geometry-buffer-shape.js | 2 +- src/r3-d3-api-geometry-buffer-sphere.js | 2 +- src/r3-d3-api-geometry-buffer-tetrahedron.js | 2 +- src/r3-d3-api-geometry-buffer-text.js | 2 +- src/r3-d3-api-geometry-buffer-torus-knot.js | 2 +- src/r3-d3-api-geometry-buffer-torus.js | 2 +- src/r3-d3-api-geometry-buffer-tube.js | 2 +- src/r3-d3-api-geometry-normal-box.js | 2 +- src/r3-d3-api-geometry-normal-circle.js | 2 +- src/r3-d3-api-geometry-normal-cone.js | 2 +- src/r3-d3-api-geometry-normal-cylinder.js | 2 +- src/r3-d3-api-geometry-normal-dodecahedron.js | 2 +- src/r3-d3-api-geometry-normal-edges.js | 2 +- src/r3-d3-api-geometry-normal-extrude.js | 2 +- src/r3-d3-api-geometry-normal-icosahedron.js | 2 +- src/r3-d3-api-geometry-normal-lathe.js | 2 +- src/r3-d3-api-geometry-normal-octahedron.js | 2 +- src/r3-d3-api-geometry-normal-parametric.js | 2 +- src/r3-d3-api-geometry-normal-plane.js | 2 +- src/r3-d3-api-geometry-normal-polyhedron.js | 2 +- src/r3-d3-api-geometry-normal-ring.js | 2 +- src/r3-d3-api-geometry-normal-shape.js | 2 +- src/r3-d3-api-geometry-normal-sphere.js | 2 +- src/r3-d3-api-geometry-normal-tetrahedron.js | 2 +- src/r3-d3-api-geometry-normal-text.js | 2 +- src/r3-d3-api-geometry-normal-torus-knot.js | 2 +- src/r3-d3-api-geometry-normal-torus.js | 2 +- src/r3-d3-api-geometry-normal-tube.js | 2 +- src/r3-d3-api-geometry-normal-wireframe.js | 2 +- src/r3-d3-api-light-a.js | 2 +- src/r3-d3-api-material-a.js | 2 +- src/r3-d3-api-material-basic.js | 2 +- src/r3-d3-api-material-phong.js | 2 +- src/r3-d3-api-material-points.js | 2 +- src/r3-d3-api-material-shader-a.js | 2 +- src/r3-d3-api-material-standard.js | 2 +- src/r3-d3-api-particle.js | 2 +- src/r3-d3-api-pass-0.js | 2 +- src/r3-d3-api-physics-world.js | 2 +- src/r3-d3-api-raycast-vehicle.js | 2 +- src/r3-d3-api-raycast-wheel.js | 2 +- src/r3-d3-api-raycaster.js | 2 +- src/r3-d3-api-render-target-a.js | 23 +- src/r3-d3-api-render-target-cube.js | 10 +- src/r3-d3-api-rigid-body.js | 2 +- src/r3-d3-api-scene.js | 2 +- src/r3-d3-api-shader-a.js | 2 +- src/r3-d3-api-shadow-a.js | 2 +- src/r3-d3-api-shape.js | 2 +- src/r3-d3-api-skeleton.js | 2 +- src/r3-d3-api-solver.js | 2 +- src/r3-d3-api-spline.js | 2 +- src/r3-d3-api-text.js | 2 +- src/r3-d3-api-texture-canvas.js | 2 +- src/r3-d3-api-texture-cube.js | 2 +- src/r3-d3-api-texture-image.js | 2 +- src/r3-d3-api-texture.js | 4 +- src/r3-d3-api-viewport.js | 2 +- src/r3-d3-api-y-object.js | 245 +++++++++++ src/r3-d3-api-z-animation.js | 115 +---- src/r3-d3-api-z-object.js | 340 --------------- src/r3-d3-audio.js | 157 +++---- src/r3-d3-bone-weight.js | 60 ++- src/r3-d3-bone.js | 53 +-- src/r3-d3-broadphase.js | 97 +---- src/r3-d3-camera-a.js | 99 +---- src/r3-d3-camera-cube.js | 138 ++---- src/r3-d3-camera-orthographic-fixed-aspect.js | 2 +- ...r3-d3-camera-orthographic-zoomed-aspect.js | 2 +- src/r3-d3-camera-orthographic.js | 2 +- src/r3-d3-camera-perspective-stereo.js | 4 +- src/r3-d3-camera-perspective.js | 2 +- src/r3-d3-composer.js | 2 +- src/r3-d3-effect-a.js | 2 +- src/r3-d3-effect-anaglyph.js | 2 +- src/r3-d3-effect-parallax.js | 2 +- src/r3-d3-effect-stereo.js | 2 +- src/r3-d3-face.js | 6 +- src/r3-d3-font.js | 4 +- src/r3-d3-friction-contact-material.js | 2 +- src/r3-d3-friction-material.js | 2 +- src/r3-d3-geometry-buffer-box.js | 2 +- src/r3-d3-geometry-buffer-circle.js | 2 +- src/r3-d3-geometry-buffer-cone.js | 2 +- src/r3-d3-geometry-buffer-cylinder.js | 2 +- src/r3-d3-geometry-buffer-dodecahedron.js | 2 +- src/r3-d3-geometry-buffer-extrude.js | 2 +- src/r3-d3-geometry-buffer-icosahedron.js | 2 +- src/r3-d3-geometry-buffer-instanced.js | 2 +- src/r3-d3-geometry-buffer-lathe.js | 2 +- src/r3-d3-geometry-buffer-octahedron.js | 2 +- src/r3-d3-geometry-buffer-parametric.js | 2 +- src/r3-d3-geometry-buffer-plane.js | 2 +- src/r3-d3-geometry-buffer-polyhedron.js | 2 +- src/r3-d3-geometry-buffer-ring.js | 2 +- src/r3-d3-geometry-buffer-shape.js | 2 +- src/r3-d3-geometry-buffer-sphere.js | 2 +- src/r3-d3-geometry-buffer-tetrahedron.js | 2 +- src/r3-d3-geometry-buffer-text.js | 2 +- src/r3-d3-geometry-buffer-torus-knot.js | 2 +- src/r3-d3-geometry-buffer-torus.js | 2 +- src/r3-d3-geometry-buffer-tube.js | 2 +- src/r3-d3-geometry-normal-box.js | 2 +- src/r3-d3-geometry-normal-circle.js | 2 +- src/r3-d3-geometry-normal-cone.js | 2 +- src/r3-d3-geometry-normal-cylinder.js | 2 +- src/r3-d3-geometry-normal-dodecahedron.js | 2 +- src/r3-d3-geometry-normal-edges.js | 2 +- src/r3-d3-geometry-normal-extrude.js | 2 +- src/r3-d3-geometry-normal-icosahedron.js | 2 +- src/r3-d3-geometry-normal-lathe.js | 2 +- src/r3-d3-geometry-normal-octahedron.js | 2 +- src/r3-d3-geometry-normal-parametric.js | 2 +- src/r3-d3-geometry-normal-plane.js | 2 +- src/r3-d3-geometry-normal-polyhedron.js | 2 +- src/r3-d3-geometry-normal-ring.js | 2 +- src/r3-d3-geometry-normal-shape.js | 2 +- src/r3-d3-geometry-normal-sphere.js | 2 +- src/r3-d3-geometry-normal-tetrahedron.js | 2 +- src/r3-d3-geometry-normal-text.js | 2 +- src/r3-d3-geometry-normal-torus-knot.js | 2 +- src/r3-d3-geometry-normal-torus.js | 2 +- src/r3-d3-geometry-normal-tube.js | 2 +- src/r3-d3-geometry-normal-wireframe.js | 2 +- src/r3-d3-helper.js | 2 +- src/r3-d3-light-a.js | 2 +- src/r3-d3-light-ambient.js | 2 +- src/r3-d3-light-directional.js | 2 +- src/r3-d3-light-hemisphere.js | 2 +- src/r3-d3-light-point.js | 2 +- src/r3-d3-light-rect-area.js | 2 +- src/r3-d3-light-spot.js | 2 +- src/r3-d3-material-a.js | 2 +- src/r3-d3-mesh-0.js | 12 +- src/r3-d3-particle-engine.js | 2 +- src/r3-d3-particle.js | 2 +- src/r3-d3-pass-0.js | 2 +- src/r3-d3-pass-bloom.js | 2 +- src/r3-d3-pass-fxaa.js | 2 +- src/r3-d3-pass-render.js | 2 +- src/r3-d3-pass-ssao.js | 2 +- src/r3-d3-physics-world.js | 8 +- src/r3-d3-raycast-vehicle.js | 2 +- src/r3-d3-raycast-wheel.js | 2 +- src/r3-d3-raycaster.js | 2 +- src/r3-d3-render-target-a.js | 324 ++++---------- src/r3-d3-render-target-cube.js | 2 +- src/r3-d3-rigid-body.js | 2 +- src/r3-d3-shader-a.js | 2 +- src/r3-d3-shader-fragment.js | 2 +- src/r3-d3-shader-vertex.js | 2 +- src/r3-d3-shadow-a.js | 2 +- src/r3-d3-shadow-directional.js | 2 +- src/r3-d3-shadow-spot.js | 2 +- src/r3-d3-shape-0.js | 4 +- src/r3-d3-skeleton.js | 4 +- src/r3-d3-solver.js | 2 +- src/r3-d3-spline.js | 4 +- src/r3-d3-texture-a.js | 2 +- src/r3-d3-viewport.js | 2 +- src/r3-graphics-runtime-a.js | 40 -- src/r3-graphics-runtime-three.js | 84 ---- src/r3-gui-runtime.js | 59 --- src/r3-gui.js | 2 +- src/r3-physics-runtime-cannon.js | 38 -- src/r3-physics-runtime.js | 35 -- src/r3-plane.js | 4 +- src/r3-renderer-d3-canvas-target.js | 2 +- src/r3-renderer-d3-canvas.js | 2 +- src/r3-renderer-d3-target.js | 2 +- src/r3-renderer-d3.js | 2 +- src/r3-runtime-coder-codemirror.js | 19 + src/r3-runtime-coder.js | 11 + src/r3-runtime-graphics-three.js | 408 ++++++++++++++++++ src/r3-runtime-graphics.js | 107 +++++ src/r3-runtime-gui-datgui.js | 19 + src/r3-runtime-gui.js | 12 + src/r3-runtime-physics-cannon.js | 60 +++ src/r3-runtime-physics.js | 40 ++ src/r3-runtime-sockets-websockjet.js | 24 ++ src/r3-runtime-sockets.js | 16 + src/r3-runtime-statistics-stats.js | 21 + src/r3-runtime-statistics.js | 12 + src/r3-runtime.js | 10 + src/r3-sockets-runtime.js | 66 --- src/r3-statistics-runtime.js | 59 --- src/r3-stats.js | 2 +- src/r3-system-gui.js | 12 +- 258 files changed, 2274 insertions(+), 2831 deletions(-) rename src/{r3-a-4-component-a.js => r3-a-4-component.js} (93%) rename src/{r3-api-curve-a.js => r3-api-curve-0.js} (93%) delete mode 100644 src/r3-coder-runtime.js create mode 100644 src/r3-controls-d3.js rename src/{r3-d3-api-a-object.js => r3-d3-api-0-object.js} (97%) create mode 100644 src/r3-d3-api-y-object.js delete mode 100644 src/r3-d3-api-z-object.js delete mode 100644 src/r3-graphics-runtime-a.js delete mode 100644 src/r3-graphics-runtime-three.js delete mode 100644 src/r3-gui-runtime.js delete mode 100644 src/r3-physics-runtime-cannon.js delete mode 100644 src/r3-physics-runtime.js create mode 100644 src/r3-runtime-coder-codemirror.js create mode 100644 src/r3-runtime-coder.js create mode 100644 src/r3-runtime-graphics-three.js create mode 100644 src/r3-runtime-graphics.js create mode 100644 src/r3-runtime-gui-datgui.js create mode 100644 src/r3-runtime-gui.js create mode 100644 src/r3-runtime-physics-cannon.js create mode 100644 src/r3-runtime-physics.js create mode 100644 src/r3-runtime-sockets-websockjet.js create mode 100644 src/r3-runtime-sockets.js create mode 100644 src/r3-runtime-statistics-stats.js create mode 100644 src/r3-runtime-statistics.js create mode 100644 src/r3-runtime.js delete mode 100644 src/r3-sockets-runtime.js delete mode 100644 src/r3-statistics-runtime.js diff --git a/gulpfile.js b/gulpfile.js index 19d2147..70b3336 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -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', diff --git a/src/r3-a-2-utils.js b/src/r3-a-2-utils.js index 6f5281b..9354f09 100644 --- a/src/r3-a-2-utils.js +++ b/src/r3-a-2-utils.js @@ -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} */ diff --git a/src/r3-a-4-component-a.js b/src/r3-a-4-component.js similarity index 93% rename from src/r3-a-4-component-a.js rename to src/r3-a-4-component.js index c8204bf..5b4784b 100644 --- a/src/r3-a-4-component-a.js +++ b/src/r3-a-4-component.js @@ -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; -}; \ No newline at end of file +}; diff --git a/src/r3-api-clock.js b/src/r3-api-clock.js index 3639b8e..7e8a02b 100644 --- a/src/r3-api-clock.js +++ b/src/r3-api-clock.js @@ -7,7 +7,7 @@ R3.API.Clock = function( apiComponent ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; }; diff --git a/src/r3-api-controls-0.js b/src/r3-api-controls-0.js index b3761b5..063a1b5 100644 --- a/src/r3-api-controls-0.js +++ b/src/r3-api-controls-0.js @@ -9,7 +9,7 @@ R3.API.Controls = function( canvas ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(canvas)) { /** diff --git a/src/r3-api-curve-a.js b/src/r3-api-curve-0.js similarity index 93% rename from src/r3-api-curve-a.js rename to src/r3-api-curve-0.js index 4179d46..ab24bee 100644 --- a/src/r3-api-curve-a.js +++ b/src/r3-api-curve-0.js @@ -9,7 +9,7 @@ R3.API.Curve = function( arcLenghDivisions ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(arcLenghDivisions)) { arcLenghDivisions = 200; diff --git a/src/r3-api-custom-code.js b/src/r3-api-custom-code.js index 045f894..622b3de 100644 --- a/src/r3-api-custom-code.js +++ b/src/r3-api-custom-code.js @@ -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; diff --git a/src/r3-api-dom-element.js b/src/r3-api-dom-element.js index 05ff5bc..7d36479 100644 --- a/src/r3-api-dom-element.js +++ b/src/r3-api-dom-element.js @@ -9,7 +9,7 @@ R3.API.DomElement = function( domElementId ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(domElementId)) { domElementId = ''; diff --git a/src/r3-api-draw-range.js b/src/r3-api-draw-range.js index a11fdcf..117d324 100644 --- a/src/r3-api-draw-range.js +++ b/src/r3-api-draw-range.js @@ -11,7 +11,7 @@ R3.API.DrawRange = function( count ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(start)) { start = 0; diff --git a/src/r3-api-entity-manager.js b/src/r3-api-entity-manager.js index cc7a44c..389131c 100644 --- a/src/r3-api-entity-manager.js +++ b/src/r3-api-entity-manager.js @@ -9,7 +9,7 @@ R3.API.EntityManager = function( entities ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(entities)) { entities = []; diff --git a/src/r3-api-entity.js b/src/r3-api-entity.js index 42ff8b1..49e5e55 100644 --- a/src/r3-api-entity.js +++ b/src/r3-api-entity.js @@ -9,7 +9,7 @@ R3.API.Entity = function( components ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(components)) { components = []; diff --git a/src/r3-api-group.js b/src/r3-api-group.js index 924e8a1..434385c 100644 --- a/src/r3-api-group.js +++ b/src/r3-api-group.js @@ -13,7 +13,7 @@ R3.API.Group = function( materialIndex ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(start)) { start = 0; diff --git a/src/r3-api-gui.js b/src/r3-api-gui.js index 0923812..7e42b17 100644 --- a/src/r3-api-gui.js +++ b/src/r3-api-gui.js @@ -9,7 +9,7 @@ R3.API.GUI = function( domElement ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(domElement)) { domElement = null; diff --git a/src/r3-api-image.js b/src/r3-api-image.js index a5ef388..fda5580 100644 --- a/src/r3-api-image.js +++ b/src/r3-api-image.js @@ -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); diff --git a/src/r3-api-mouse.js b/src/r3-api-mouse.js index fb17551..117141d 100644 --- a/src/r3-api-mouse.js +++ b/src/r3-api-mouse.js @@ -11,7 +11,7 @@ R3.API.Mouse = function( y ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(x)) { x = 0; diff --git a/src/r3-api-plane.js b/src/r3-api-plane.js index c2bd19b..f5aca4a 100644 --- a/src/r3-api-plane.js +++ b/src/r3-api-plane.js @@ -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); diff --git a/src/r3-api-project.js b/src/r3-api-project.js index 0720555..0f52924 100644 --- a/src/r3-api-project.js +++ b/src/r3-api-project.js @@ -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; } diff --git a/src/r3-api-renderer-a.js b/src/r3-api-renderer-a.js index ad56170..0d03a3a 100644 --- a/src/r3-api-renderer-a.js +++ b/src/r3-api-renderer-a.js @@ -7,7 +7,7 @@ R3.API.Renderer = function( apiComponent ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; }; diff --git a/src/r3-api-server.js b/src/r3-api-server.js index ccbe53f..caa7ac7 100644 --- a/src/r3-api-server.js +++ b/src/r3-api-server.js @@ -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; diff --git a/src/r3-api-socket-0.js b/src/r3-api-socket-0.js index 6689877..7039bd9 100644 --- a/src/r3-api-socket-0.js +++ b/src/r3-api-socket-0.js @@ -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(); diff --git a/src/r3-api-sphere.js b/src/r3-api-sphere.js index 8aece3f..53be1e5 100644 --- a/src/r3-api-sphere.js +++ b/src/r3-api-sphere.js @@ -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); diff --git a/src/r3-api-stats.js b/src/r3-api-stats.js index 7841d4d..762b4c0 100644 --- a/src/r3-api-stats.js +++ b/src/r3-api-stats.js @@ -9,7 +9,7 @@ R3.API.Stats = function( domElement ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(domElement)) { domElement = null; diff --git a/src/r3-api-user.js b/src/r3-api-user.js index bcb0e6d..ce78fa6 100644 --- a/src/r3-api-user.js +++ b/src/r3-api-user.js @@ -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'); diff --git a/src/r3-api-video.js b/src/r3-api-video.js index dba474b..900e483 100644 --- a/src/r3-api-video.js +++ b/src/r3-api-video.js @@ -17,7 +17,7 @@ R3.API.Video = function( source ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(autoUpdateSize)) { autoUpdateSize = true; diff --git a/src/r3-box3.js b/src/r3-box3.js index 6220315..5651f1f 100644 --- a/src/r3-box3.js +++ b/src/r3-box3.js @@ -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); + }; diff --git a/src/r3-canvas.js b/src/r3-canvas.js index beb76b9..692492f 100644 --- a/src/r3-canvas.js +++ b/src/r3-canvas.js @@ -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) diff --git a/src/r3-clock.js b/src/r3-clock.js index fe3a9a0..df3939d 100644 --- a/src/r3-clock.js +++ b/src/r3-clock.js @@ -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 - ); - -}; diff --git a/src/r3-coder-runtime.js b/src/r3-coder-runtime.js deleted file mode 100644 index ae1ef1b..0000000 --- a/src/r3-coder-runtime.js +++ /dev/null @@ -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'); - } -}; - \ No newline at end of file diff --git a/src/r3-color.js b/src/r3-color.js index fdf5680..72bf557 100644 --- a/src/r3-color.js +++ b/src/r3-color.js @@ -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; } }; diff --git a/src/r3-controls-0.js b/src/r3-controls-0.js index 3c2e715..243fbc8 100644 --- a/src/r3-controls-0.js +++ b/src/r3-controls-0.js @@ -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; -}; diff --git a/src/r3-controls-d3-editor.js b/src/r3-controls-d3-editor.js index 5854336..b17c45e 100644 --- a/src/r3-controls-d3-editor.js +++ b/src/r3-controls-d3-editor.js @@ -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); }; diff --git a/src/r3-controls-d3-first-person.js b/src/r3-controls-d3-first-person.js index 0d8d581..5b66518 100644 --- a/src/r3-controls-d3-first-person.js +++ b/src/r3-controls-d3-first-person.js @@ -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); }; diff --git a/src/r3-controls-d3-orbit.js b/src/r3-controls-d3-orbit.js index cfdbaed..ff05f7b 100644 --- a/src/r3-controls-d3-orbit.js +++ b/src/r3-controls-d3-orbit.js @@ -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); }; diff --git a/src/r3-controls-d3.js b/src/r3-controls-d3.js new file mode 100644 index 0000000..2aebaee --- /dev/null +++ b/src/r3-controls-d3.js @@ -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); + +}; \ No newline at end of file diff --git a/src/r3-controls-keyboard.js b/src/r3-controls-keyboard.js index c949be4..d54b4e2 100644 --- a/src/r3-controls-keyboard.js +++ b/src/r3-controls-keyboard.js @@ -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 - ); - -}; \ No newline at end of file diff --git a/src/r3-controls-mouse.js b/src/r3-controls-mouse.js index ff52f7a..24c0ac7 100644 --- a/src/r3-controls-mouse.js +++ b/src/r3-controls-mouse.js @@ -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 - ); - -}; \ No newline at end of file diff --git a/src/r3-controls-touch.js b/src/r3-controls-touch.js index 4770d55..e64b4b8 100644 --- a/src/r3-controls-touch.js +++ b/src/r3-controls-touch.js @@ -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); - -}; \ No newline at end of file diff --git a/src/r3-curve-a.js b/src/r3-curve-a.js index d09347b..f1df359 100644 --- a/src/r3-curve-a.js +++ b/src/r3-curve-a.js @@ -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 - ); - -}; diff --git a/src/r3-curve-path-a.js b/src/r3-curve-path-a.js index a6a74df..4ea2f99 100644 --- a/src/r3-curve-path-a.js +++ b/src/r3-curve-path-a.js @@ -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; -}; diff --git a/src/r3-curve-path-d2-a.js b/src/r3-curve-path-d2-a.js index 12c1b2b..23dd701 100644 --- a/src/r3-curve-path-d2-a.js +++ b/src/r3-curve-path-d2-a.js @@ -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(); - } - ) - ); - -}; diff --git a/src/r3-curve-path-d2-shape.js b/src/r3-curve-path-d2-shape.js index 0249956..0a9d9fe 100644 --- a/src/r3-curve-path-d2-shape.js +++ b/src/r3-curve-path-d2-shape.js @@ -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 - ); - -}; diff --git a/src/r3-custom-code.js b/src/r3-custom-code.js index 3bad8d1..e0113b7 100644 --- a/src/r3-custom-code.js +++ b/src/r3-custom-code.js @@ -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, diff --git a/src/r3-d3-api-a-object.js b/src/r3-d3-api-0-object.js similarity index 97% rename from src/r3-d3-api-a-object.js rename to src/r3-d3-api-0-object.js index 2974177..3fc2b25 100644 --- a/src/r3-d3-api-a-object.js +++ b/src/r3-d3-api-0-object.js @@ -21,7 +21,7 @@ R3.D3.API.Object = function( lookAt ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(useQuaternion)) { useQuaternion = true; diff --git a/src/r3-d3-api-animation.js b/src/r3-d3-api-animation.js index 63761e8..ad454cf 100644 --- a/src/r3-d3-api-animation.js +++ b/src/r3-d3-api-animation.js @@ -23,7 +23,7 @@ R3.D3.API.Animation = function( applyToMeshWhenDone ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(rotationSpeed)) { rotationSpeed = 0; diff --git a/src/r3-d3-api-audio.js b/src/r3-d3-api-audio.js index 8719e57..0a64268 100644 --- a/src/r3-d3-api-audio.js +++ b/src/r3-d3-api-audio.js @@ -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; diff --git a/src/r3-d3-api-bone-weight.js b/src/r3-d3-api-bone-weight.js index 9e44156..f33cf77 100644 --- a/src/r3-d3-api-bone-weight.js +++ b/src/r3-d3-api-bone-weight.js @@ -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; diff --git a/src/r3-d3-api-broadphase.js b/src/r3-d3-api-broadphase.js index 8570921..822cd3c 100644 --- a/src/r3-d3-api-broadphase.js +++ b/src/r3-d3-api-broadphase.js @@ -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; diff --git a/src/r3-d3-api-camera-cube.js b/src/r3-d3-api-camera-cube.js index 41b225b..6440eef 100644 --- a/src/r3-d3-api-camera-cube.js +++ b/src/r3-d3-api-camera-cube.js @@ -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; diff --git a/src/r3-d3-api-composer.js b/src/r3-d3-api-composer.js index 23b0de1..f65220b 100644 --- a/src/r3-d3-api-composer.js +++ b/src/r3-d3-api-composer.js @@ -15,7 +15,7 @@ R3.D3.API.Composer = function( passes ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(autoUpdateSize)) { autoUpdateSize = true; diff --git a/src/r3-d3-api-effect-a.js b/src/r3-d3-api-effect-a.js index b8fd240..e77e856 100644 --- a/src/r3-d3-api-effect-a.js +++ b/src/r3-d3-api-effect-a.js @@ -14,7 +14,7 @@ R3.D3.API.Effect = function( height ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(width)) { width = 512; diff --git a/src/r3-d3-api-face.js b/src/r3-d3-api-face.js index 7354ba3..7493177 100644 --- a/src/r3-d3-api-face.js +++ b/src/r3-d3-api-face.js @@ -27,7 +27,7 @@ R3.D3.API.Face = function( selected ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(v0index)) { v0index = -1; diff --git a/src/r3-d3-api-fog.js b/src/r3-d3-api-fog.js index 9ff0ea0..ea8189a 100644 --- a/src/r3-d3-api-fog.js +++ b/src/r3-d3-api-fog.js @@ -17,7 +17,7 @@ R3.D3.API.Fog = function( density ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(exponential)) { exponential = false; diff --git a/src/r3-d3-api-font.js b/src/r3-d3-api-font.js index 3cc8e2e..f10a36e 100644 --- a/src/r3-d3-api-font.js +++ b/src/r3-d3-api-font.js @@ -9,7 +9,7 @@ R3.D3.API.Font = function( path ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(path)) { path = ''; diff --git a/src/r3-d3-api-friction-contact-material.js b/src/r3-d3-api-friction-contact-material.js index 70bc262..61d951d 100644 --- a/src/r3-d3-api-friction-contact-material.js +++ b/src/r3-d3-api-friction-contact-material.js @@ -21,7 +21,7 @@ R3.D3.API.FrictionContactMaterial = function( frictionEquationRelaxation ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(materials)) { materials = []; diff --git a/src/r3-d3-api-friction-material.js b/src/r3-d3-api-friction-material.js index a3f26ef..9b5e770 100644 --- a/src/r3-d3-api-friction-material.js +++ b/src/r3-d3-api-friction-material.js @@ -11,7 +11,7 @@ R3.D3.API.FrictionMaterial = function( restitution ) { - __API_COMPONENT_MACRO__ + __API_COMPONENT_MACRO__; if (R3.Utils.UndefinedOrNull(friction)) { friction = -1; diff --git a/src/r3-d3-api-geometry-a.js b/src/r3-d3-api-geometry-a.js index 745a128..d3a52b3 100644 --- a/src/r3-d3-api-geometry-a.js +++ b/src/r3-d3-api-geometry-a.js @@ -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(); diff --git a/src/r3-d3-api-geometry-buffer-box.js b/src/r3-d3-api-geometry-buffer-box.js index fafea83..075adb5 100644 --- a/src/r3-d3-api-geometry-buffer-box.js +++ b/src/r3-d3-api-geometry-buffer-box.js @@ -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; diff --git a/src/r3-d3-api-geometry-buffer-circle.js b/src/r3-d3-api-geometry-buffer-circle.js index 628c06e..5290072 100644 --- a/src/r3-d3-api-geometry-buffer-circle.js +++ b/src/r3-d3-api-geometry-buffer-circle.js @@ -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; diff --git a/src/r3-d3-api-geometry-buffer-cone.js b/src/r3-d3-api-geometry-buffer-cone.js index 6969b5c..1475610 100644 --- a/src/r3-d3-api-geometry-buffer-cone.js +++ b/src/r3-d3-api-geometry-buffer-cone.js @@ -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; diff --git a/src/r3-d3-api-geometry-buffer-cylinder.js b/src/r3-d3-api-geometry-buffer-cylinder.js index bd2628c..dcefebb 100644 --- a/src/r3-d3-api-geometry-buffer-cylinder.js +++ b/src/r3-d3-api-geometry-buffer-cylinder.js @@ -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; diff --git a/src/r3-d3-api-geometry-buffer-dodecahedron.js b/src/r3-d3-api-geometry-buffer-dodecahedron.js index 5446a5e..22a652d 100644 --- a/src/r3-d3-api-geometry-buffer-dodecahedron.js +++ b/src/r3-d3-api-geometry-buffer-dodecahedron.js @@ -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; diff --git a/src/r3-d3-api-geometry-buffer-extrude.js b/src/r3-d3-api-geometry-buffer-extrude.js index c2235cc..e76d2ed 100644 --- a/src/r3-d3-api-geometry-buffer-extrude.js +++ b/src/r3-d3-api-geometry-buffer-extrude.js @@ -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 = []; diff --git a/src/r3-d3-api-geometry-buffer-icosahedron.js b/src/r3-d3-api-geometry-buffer-icosahedron.js index 328a11f..340caf7 100644 --- a/src/r3-d3-api-geometry-buffer-icosahedron.js +++ b/src/r3-d3-api-geometry-buffer-icosahedron.js @@ -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; diff --git a/src/r3-d3-api-geometry-buffer-instanced.js b/src/r3-d3-api-geometry-buffer-instanced.js index 6f5849a..93dca19 100644 --- a/src/r3-d3-api-geometry-buffer-instanced.js +++ b/src/r3-d3-api-geometry-buffer-instanced.js @@ -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; diff --git a/src/r3-d3-api-geometry-buffer-lathe.js b/src/r3-d3-api-geometry-buffer-lathe.js index c6bd9b1..3e2ba7b 100644 --- a/src/r3-d3-api-geometry-buffer-lathe.js +++ b/src/r3-d3-api-geometry-buffer-lathe.js @@ -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 = []; diff --git a/src/r3-d3-api-geometry-buffer-octahedron.js b/src/r3-d3-api-geometry-buffer-octahedron.js index 2300e59..b863689 100644 --- a/src/r3-d3-api-geometry-buffer-octahedron.js +++ b/src/r3-d3-api-geometry-buffer-octahedron.js @@ -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; diff --git a/src/r3-d3-api-geometry-buffer-parametric.js b/src/r3-d3-api-geometry-buffer-parametric.js index 232b519..65c5fc5 100644 --- a/src/r3-d3-api-geometry-buffer-parametric.js +++ b/src/r3-d3-api-geometry-buffer-parametric.js @@ -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 = ''; diff --git a/src/r3-d3-api-geometry-buffer-plane.js b/src/r3-d3-api-geometry-buffer-plane.js index 227ef77..0a2d413 100644 --- a/src/r3-d3-api-geometry-buffer-plane.js +++ b/src/r3-d3-api-geometry-buffer-plane.js @@ -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; diff --git a/src/r3-d3-api-geometry-buffer-polyhedron.js b/src/r3-d3-api-geometry-buffer-polyhedron.js index f392036..562a3d1 100644 --- a/src/r3-d3-api-geometry-buffer-polyhedron.js +++ b/src/r3-d3-api-geometry-buffer-polyhedron.js @@ -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 = []; diff --git a/src/r3-d3-api-geometry-buffer-ring.js b/src/r3-d3-api-geometry-buffer-ring.js index 6a3009b..d2aed7c 100644 --- a/src/r3-d3-api-geometry-buffer-ring.js +++ b/src/r3-d3-api-geometry-buffer-ring.js @@ -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; diff --git a/src/r3-d3-api-geometry-buffer-shape.js b/src/r3-d3-api-geometry-buffer-shape.js index 789acf8..339c652 100644 --- a/src/r3-d3-api-geometry-buffer-shape.js +++ b/src/r3-d3-api-geometry-buffer-shape.js @@ -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 = []; diff --git a/src/r3-d3-api-geometry-buffer-sphere.js b/src/r3-d3-api-geometry-buffer-sphere.js index dfe482a..7f8604e 100644 --- a/src/r3-d3-api-geometry-buffer-sphere.js +++ b/src/r3-d3-api-geometry-buffer-sphere.js @@ -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; diff --git a/src/r3-d3-api-geometry-buffer-tetrahedron.js b/src/r3-d3-api-geometry-buffer-tetrahedron.js index f6b153b..9a531f4 100644 --- a/src/r3-d3-api-geometry-buffer-tetrahedron.js +++ b/src/r3-d3-api-geometry-buffer-tetrahedron.js @@ -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; diff --git a/src/r3-d3-api-geometry-buffer-text.js b/src/r3-d3-api-geometry-buffer-text.js index c418236..bdb91a3 100644 --- a/src/r3-d3-api-geometry-buffer-text.js +++ b/src/r3-d3-api-geometry-buffer-text.js @@ -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 = '-=