From f20ed1760f0556e0ccaef103d362d6f3755e607f Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Sun, 11 Feb 2018 16:57:28 +0100 Subject: [PATCH] geometry done --- src/game-lib-a-component-a.js | 642 +++++++++--------- src/game-lib-box3.js | 12 + src/game-lib-d3-api-buffer-geometry-0.js | 269 -------- src/game-lib-d3-api-buffer-geometry-box.js | 81 --- src/game-lib-d3-api-buffer-geometry-circle.js | 67 -- src/game-lib-d3-api-buffer-geometry-cone.js | 88 --- ...lib-d3-api-buffer-geometry-dodecahedron.js | 53 -- ...-lib-d3-api-buffer-geometry-icosahedron.js | 53 -- src/game-lib-d3-api-buffer-geometry-lathe.js | 67 -- ...e-lib-d3-api-buffer-geometry-octahedron.js | 53 -- ...e-lib-d3-api-buffer-geometry-parametric.js | 60 -- src/game-lib-d3-api-buffer-geometry-plane.js | 67 -- ...e-lib-d3-api-buffer-geometry-polyhedron.js | 67 -- src/game-lib-d3-api-buffer-geometry-ring.js | 81 --- src/game-lib-d3-api-buffer-geometry-shape.js | 53 -- src/game-lib-d3-api-buffer-geometry-sphere.js | 88 --- ...-lib-d3-api-buffer-geometry-tetrahedron.js | 53 -- ...e-lib-d3-api-buffer-geometry-torus-knot.js | 81 --- src/game-lib-d3-api-buffer-geometry-torus.js | 74 -- src/game-lib-d3-api-buffer-geometry-tube.js | 74 -- src/game-lib-d3-api-geometry-a.js | 398 +++++++---- src/game-lib-d3-api-geometry-b.js | 342 ---------- src/game-lib-d3-api-geometry-buffer-a.js | 69 ++ src/game-lib-d3-api-geometry-buffer-box.js | 74 ++ src/game-lib-d3-api-geometry-buffer-circle.js | 60 ++ src/game-lib-d3-api-geometry-buffer-cone.js | 81 +++ ...me-lib-d3-api-geometry-buffer-cylinder.js} | 43 +- ...lib-d3-api-geometry-buffer-dodecahedron.js | 46 ++ ...ame-lib-d3-api-geometry-buffer-extrude.js} | 43 +- ...-lib-d3-api-geometry-buffer-icosahedron.js | 46 ++ src/game-lib-d3-api-geometry-buffer-lathe.js | 60 ++ ...e-lib-d3-api-geometry-buffer-octahedron.js | 46 ++ ...e-lib-d3-api-geometry-buffer-parametric.js | 53 ++ src/game-lib-d3-api-geometry-buffer-plane.js | 60 ++ ...e-lib-d3-api-geometry-buffer-polyhedron.js | 60 ++ src/game-lib-d3-api-geometry-buffer-ring.js | 74 ++ src/game-lib-d3-api-geometry-buffer-shape.js | 46 ++ src/game-lib-d3-api-geometry-buffer-sphere.js | 81 +++ ...-lib-d3-api-geometry-buffer-tetrahedron.js | 46 ++ ...> game-lib-d3-api-geometry-buffer-text.js} | 49 +- ...e-lib-d3-api-geometry-buffer-torus-knot.js | 74 ++ src/game-lib-d3-api-geometry-buffer-torus.js | 67 ++ src/game-lib-d3-api-geometry-buffer-tube.js | 67 ++ src/game-lib-d3-api-geometry-dodecahedron.js | 63 -- src/game-lib-d3-api-geometry-edges.js | 63 -- src/game-lib-d3-api-geometry-icosahedron.js | 63 -- src/game-lib-d3-api-geometry-normal-a.js | 125 ++++ ...=> game-lib-d3-api-geometry-normal-box.js} | 49 +- ...game-lib-d3-api-geometry-normal-circle.js} | 49 +- ...> game-lib-d3-api-geometry-normal-cone.js} | 49 +- ...me-lib-d3-api-geometry-normal-cylinder.js} | 49 +- ...lib-d3-api-geometry-normal-dodecahedron.js | 54 ++ src/game-lib-d3-api-geometry-normal-edges.js | 54 ++ ...ame-lib-d3-api-geometry-normal-extrude.js} | 49 +- ...-lib-d3-api-geometry-normal-icosahedron.js | 54 ++ ... game-lib-d3-api-geometry-normal-lathe.js} | 49 +- ...e-lib-d3-api-geometry-normal-octahedron.js | 54 ++ ...-lib-d3-api-geometry-normal-parametric.js} | 49 +- ... game-lib-d3-api-geometry-normal-plane.js} | 49 +- ...-lib-d3-api-geometry-normal-polyhedron.js} | 49 +- ...> game-lib-d3-api-geometry-normal-ring.js} | 49 +- src/game-lib-d3-api-geometry-normal-shape.js | 54 ++ ...game-lib-d3-api-geometry-normal-sphere.js} | 51 +- ...-lib-d3-api-geometry-normal-tetrahedron.js | 54 ++ ...> game-lib-d3-api-geometry-normal-text.js} | 55 +- ...-lib-d3-api-geometry-normal-torus-knot.js} | 49 +- ... game-lib-d3-api-geometry-normal-torus.js} | 49 +- ...> game-lib-d3-api-geometry-normal-tube.js} | 49 +- ...me-lib-d3-api-geometry-normal-wireframe.js | 47 ++ src/game-lib-d3-api-geometry-octahedron.js | 63 -- src/game-lib-d3-api-geometry-shape.js | 63 -- src/game-lib-d3-api-geometry-tetrahedron.js | 63 -- src/game-lib-d3-api-geometry-wireframe.js | 54 -- src/game-lib-d3-buffer-geometry-box.js | 103 --- src/game-lib-d3-font.js | 14 +- src/game-lib-d3-geometry-a.js | 464 ++----------- ...-a.js => game-lib-d3-geometry-buffer-a.js} | 284 ++++---- src/game-lib-d3-geometry-buffer-box.js | 108 +++ src/game-lib-d3-geometry-buffer-circle.js | 110 +++ src/game-lib-d3-geometry-buffer-cone.js | 117 ++++ src/game-lib-d3-geometry-buffer-cylinder.js | 121 ++++ ...ame-lib-d3-geometry-buffer-dodecahedron.js | 103 +++ src/game-lib-d3-geometry-buffer-extrude.js | 146 ++++ ...game-lib-d3-geometry-buffer-icosahedron.js | 103 +++ src/game-lib-d3-geometry-buffer-lathe.js | 118 ++++ src/game-lib-d3-geometry-buffer-octahedron.js | 103 +++ src/game-lib-d3-geometry-buffer-parametric.js | 107 +++ src/game-lib-d3-geometry-buffer-plane.js | 100 +++ src/game-lib-d3-geometry-buffer-polyhedron.js | 116 ++++ src/game-lib-d3-geometry-buffer-ring.js | 113 +++ src/game-lib-d3-geometry-buffer-shape.js | 112 +++ src/game-lib-d3-geometry-buffer-sphere.js | 117 ++++ ...game-lib-d3-geometry-buffer-tetrahedron.js | 103 +++ src/game-lib-d3-geometry-buffer-text.js | 142 ++++ src/game-lib-d3-geometry-buffer-torus-knot.js | 113 +++ src/game-lib-d3-geometry-buffer-torus.js | 109 +++ src/game-lib-d3-geometry-buffer-tube.js | 109 +++ src/game-lib-d3-geometry-normal-a.js | 471 +++++++++++++ src/game-lib-d3-geometry-normal-box.js | 97 +++ src/game-lib-d3-geometry-normal-circle.js | 105 +++ src/game-lib-d3-geometry-normal-cone.js | 117 ++++ src/game-lib-d3-geometry-normal-cylinder.js | 121 ++++ ...ame-lib-d3-geometry-normal-dodecahedron.js | 97 +++ src/game-lib-d3-geometry-normal-edges.js | 108 +++ src/game-lib-d3-geometry-normal-extrude.js | 141 ++++ ...game-lib-d3-geometry-normal-icosahedron.js | 97 +++ src/game-lib-d3-geometry-normal-lathe.js | 113 +++ src/game-lib-d3-geometry-normal-octahedron.js | 97 +++ src/game-lib-d3-geometry-normal-parametric.js | 101 +++ src/game-lib-d3-geometry-normal-plane.js | 100 +++ src/game-lib-d3-geometry-normal-polyhedron.js | 116 ++++ src/game-lib-d3-geometry-normal-ring.js | 113 +++ src/game-lib-d3-geometry-normal-shape.js | 112 +++ src/game-lib-d3-geometry-normal-sphere.js | 117 ++++ ...game-lib-d3-geometry-normal-tetrahedron.js | 97 +++ src/game-lib-d3-geometry-normal-text.js | 141 ++++ src/game-lib-d3-geometry-normal-torus-knot.js | 113 +++ src/game-lib-d3-geometry-normal-torus.js | 109 +++ src/game-lib-d3-geometry-normal-tube.js | 109 +++ src/game-lib-d3-geometry-normal-wireframe.js | 104 +++ src/game-lib-d3-mesh-0.js | 8 +- src/game-lib-draw-range.js | 7 + src/game-lib-group.js | 13 +- src/game-lib-sphere.js | 6 + src/game-lib-system-gui.js | 8 +- src/game-lib-system-render.js | 6 +- 126 files changed, 8008 insertions(+), 3810 deletions(-) delete mode 100644 src/game-lib-d3-api-buffer-geometry-0.js delete mode 100644 src/game-lib-d3-api-buffer-geometry-box.js delete mode 100644 src/game-lib-d3-api-buffer-geometry-circle.js delete mode 100644 src/game-lib-d3-api-buffer-geometry-cone.js delete mode 100644 src/game-lib-d3-api-buffer-geometry-dodecahedron.js delete mode 100644 src/game-lib-d3-api-buffer-geometry-icosahedron.js delete mode 100644 src/game-lib-d3-api-buffer-geometry-lathe.js delete mode 100644 src/game-lib-d3-api-buffer-geometry-octahedron.js delete mode 100644 src/game-lib-d3-api-buffer-geometry-parametric.js delete mode 100644 src/game-lib-d3-api-buffer-geometry-plane.js delete mode 100644 src/game-lib-d3-api-buffer-geometry-polyhedron.js delete mode 100644 src/game-lib-d3-api-buffer-geometry-ring.js delete mode 100644 src/game-lib-d3-api-buffer-geometry-shape.js delete mode 100644 src/game-lib-d3-api-buffer-geometry-sphere.js delete mode 100644 src/game-lib-d3-api-buffer-geometry-tetrahedron.js delete mode 100644 src/game-lib-d3-api-buffer-geometry-torus-knot.js delete mode 100644 src/game-lib-d3-api-buffer-geometry-torus.js delete mode 100644 src/game-lib-d3-api-buffer-geometry-tube.js delete mode 100644 src/game-lib-d3-api-geometry-b.js create mode 100644 src/game-lib-d3-api-geometry-buffer-a.js create mode 100644 src/game-lib-d3-api-geometry-buffer-box.js create mode 100644 src/game-lib-d3-api-geometry-buffer-circle.js create mode 100644 src/game-lib-d3-api-geometry-buffer-cone.js rename src/{game-lib-d3-api-buffer-geometry-cylinder.js => game-lib-d3-api-geometry-buffer-cylinder.js} (52%) create mode 100644 src/game-lib-d3-api-geometry-buffer-dodecahedron.js rename src/{game-lib-d3-api-buffer-geometry-extrude.js => game-lib-d3-api-geometry-buffer-extrude.js} (57%) create mode 100644 src/game-lib-d3-api-geometry-buffer-icosahedron.js create mode 100644 src/game-lib-d3-api-geometry-buffer-lathe.js create mode 100644 src/game-lib-d3-api-geometry-buffer-octahedron.js create mode 100644 src/game-lib-d3-api-geometry-buffer-parametric.js create mode 100644 src/game-lib-d3-api-geometry-buffer-plane.js create mode 100644 src/game-lib-d3-api-geometry-buffer-polyhedron.js create mode 100644 src/game-lib-d3-api-geometry-buffer-ring.js create mode 100644 src/game-lib-d3-api-geometry-buffer-shape.js create mode 100644 src/game-lib-d3-api-geometry-buffer-sphere.js create mode 100644 src/game-lib-d3-api-geometry-buffer-tetrahedron.js rename src/{game-lib-d3-api-buffer-geometry-text.js => game-lib-d3-api-geometry-buffer-text.js} (51%) create mode 100644 src/game-lib-d3-api-geometry-buffer-torus-knot.js create mode 100644 src/game-lib-d3-api-geometry-buffer-torus.js create mode 100644 src/game-lib-d3-api-geometry-buffer-tube.js delete mode 100644 src/game-lib-d3-api-geometry-dodecahedron.js delete mode 100644 src/game-lib-d3-api-geometry-edges.js delete mode 100644 src/game-lib-d3-api-geometry-icosahedron.js create mode 100644 src/game-lib-d3-api-geometry-normal-a.js rename src/{game-lib-d3-api-geometry-box.js => game-lib-d3-api-geometry-normal-box.js} (61%) rename src/{game-lib-d3-api-geometry-circle.js => game-lib-d3-api-geometry-normal-circle.js} (54%) rename src/{game-lib-d3-api-geometry-cone.js => game-lib-d3-api-geometry-normal-cone.js} (64%) rename src/{game-lib-d3-api-geometry-cylinder.js => game-lib-d3-api-geometry-normal-cylinder.js} (66%) create mode 100644 src/game-lib-d3-api-geometry-normal-dodecahedron.js create mode 100644 src/game-lib-d3-api-geometry-normal-edges.js rename src/{game-lib-d3-api-geometry-extrude.js => game-lib-d3-api-geometry-normal-extrude.js} (69%) create mode 100644 src/game-lib-d3-api-geometry-normal-icosahedron.js rename src/{game-lib-d3-api-geometry-lathe.js => game-lib-d3-api-geometry-normal-lathe.js} (54%) create mode 100644 src/game-lib-d3-api-geometry-normal-octahedron.js rename src/{game-lib-d3-api-geometry-parametric.js => game-lib-d3-api-geometry-normal-parametric.js} (50%) rename src/{game-lib-d3-api-geometry-plane.js => game-lib-d3-api-geometry-normal-plane.js} (54%) rename src/{game-lib-d3-api-geometry-polyhedron.js => game-lib-d3-api-geometry-normal-polyhedron.js} (52%) rename src/{game-lib-d3-api-geometry-ring.js => game-lib-d3-api-geometry-normal-ring.js} (62%) create mode 100644 src/game-lib-d3-api-geometry-normal-shape.js rename src/{game-lib-d3-api-geometry-sphere.js => game-lib-d3-api-geometry-normal-sphere.js} (62%) create mode 100644 src/game-lib-d3-api-geometry-normal-tetrahedron.js rename src/{game-lib-d3-api-geometry-text.js => game-lib-d3-api-geometry-normal-text.js} (64%) rename src/{game-lib-d3-api-geometry-torus-knot.js => game-lib-d3-api-geometry-normal-torus-knot.js} (58%) rename src/{game-lib-d3-api-geometry-torus.js => game-lib-d3-api-geometry-normal-torus.js} (57%) rename src/{game-lib-d3-api-geometry-tube.js => game-lib-d3-api-geometry-normal-tube.js} (58%) create mode 100644 src/game-lib-d3-api-geometry-normal-wireframe.js delete mode 100644 src/game-lib-d3-api-geometry-octahedron.js delete mode 100644 src/game-lib-d3-api-geometry-shape.js delete mode 100644 src/game-lib-d3-api-geometry-tetrahedron.js delete mode 100644 src/game-lib-d3-api-geometry-wireframe.js delete mode 100644 src/game-lib-d3-buffer-geometry-box.js rename src/{game-lib-d3-buffer-geometry-a.js => game-lib-d3-geometry-buffer-a.js} (64%) create mode 100644 src/game-lib-d3-geometry-buffer-box.js create mode 100644 src/game-lib-d3-geometry-buffer-circle.js create mode 100644 src/game-lib-d3-geometry-buffer-cone.js create mode 100644 src/game-lib-d3-geometry-buffer-cylinder.js create mode 100644 src/game-lib-d3-geometry-buffer-dodecahedron.js create mode 100644 src/game-lib-d3-geometry-buffer-extrude.js create mode 100644 src/game-lib-d3-geometry-buffer-icosahedron.js create mode 100644 src/game-lib-d3-geometry-buffer-lathe.js create mode 100644 src/game-lib-d3-geometry-buffer-octahedron.js create mode 100644 src/game-lib-d3-geometry-buffer-parametric.js create mode 100644 src/game-lib-d3-geometry-buffer-plane.js create mode 100644 src/game-lib-d3-geometry-buffer-polyhedron.js create mode 100644 src/game-lib-d3-geometry-buffer-ring.js create mode 100644 src/game-lib-d3-geometry-buffer-shape.js create mode 100644 src/game-lib-d3-geometry-buffer-sphere.js create mode 100644 src/game-lib-d3-geometry-buffer-tetrahedron.js create mode 100644 src/game-lib-d3-geometry-buffer-text.js create mode 100644 src/game-lib-d3-geometry-buffer-torus-knot.js create mode 100644 src/game-lib-d3-geometry-buffer-torus.js create mode 100644 src/game-lib-d3-geometry-buffer-tube.js create mode 100644 src/game-lib-d3-geometry-normal-a.js create mode 100644 src/game-lib-d3-geometry-normal-box.js create mode 100644 src/game-lib-d3-geometry-normal-circle.js create mode 100644 src/game-lib-d3-geometry-normal-cone.js create mode 100644 src/game-lib-d3-geometry-normal-cylinder.js create mode 100644 src/game-lib-d3-geometry-normal-dodecahedron.js create mode 100644 src/game-lib-d3-geometry-normal-edges.js create mode 100644 src/game-lib-d3-geometry-normal-extrude.js create mode 100644 src/game-lib-d3-geometry-normal-icosahedron.js create mode 100644 src/game-lib-d3-geometry-normal-lathe.js create mode 100644 src/game-lib-d3-geometry-normal-octahedron.js create mode 100644 src/game-lib-d3-geometry-normal-parametric.js create mode 100644 src/game-lib-d3-geometry-normal-plane.js create mode 100644 src/game-lib-d3-geometry-normal-polyhedron.js create mode 100644 src/game-lib-d3-geometry-normal-ring.js create mode 100644 src/game-lib-d3-geometry-normal-shape.js create mode 100644 src/game-lib-d3-geometry-normal-sphere.js create mode 100644 src/game-lib-d3-geometry-normal-tetrahedron.js create mode 100644 src/game-lib-d3-geometry-normal-text.js create mode 100644 src/game-lib-d3-geometry-normal-torus-knot.js create mode 100644 src/game-lib-d3-geometry-normal-torus.js create mode 100644 src/game-lib-d3-geometry-normal-tube.js create mode 100644 src/game-lib-d3-geometry-normal-wireframe.js diff --git a/src/game-lib-a-component-a.js b/src/game-lib-a-component-a.js index 5a79c3a..d672570 100644 --- a/src/game-lib-a-component-a.js +++ b/src/game-lib-a-component-a.js @@ -335,61 +335,63 @@ GameLib.Component.MATERIAL_BASIC = 0x66; GameLib.Component.TEXTURE = 0x67; GameLib.Component.MATERIAL_PHONG = 0x68; -GameLib.Component.GEOMETRY = 0x69; -GameLib.Component.GEOMETRY_BOX = 0x6a; -GameLib.Component.GEOMETRY_CIRCLE = 0x6b; -GameLib.Component.GEOMETRY_CONE = 0x6c; -GameLib.Component.GEOMETRY_CYLINDER = 0x6d; -GameLib.Component.GEOMETRY_DODECAHEDRON = 0x6e; -GameLib.Component.GEOMETRY_EDGES = 0x6f; -GameLib.Component.GEOMETRY_EXTRUDE = 0x70; -GameLib.Component.GEOMETRY_ICOSAHEDRON = 0x71; -GameLib.Component.GEOMETRY_LATHE = 0x72; -GameLib.Component.GEOMETRY_OCTAHEDRON = 0x73; -GameLib.Component.GEOMETRY_PARAMETRIC = 0x74; -GameLib.Component.GEOMETRY_PLANE = 0x75; -GameLib.Component.GEOMETRY_POLYHEDRON = 0x76; -GameLib.Component.GEOMETRY_RING = 0x77; -GameLib.Component.GEOMETRY_SHAPE = 0x78; -GameLib.Component.GEOMETRY_SPHERE = 0x79; -GameLib.Component.GEOMETRY_TETRAHEDRON = 0x7a; -GameLib.Component.GEOMETRY_TEXT = 0x7b; -GameLib.Component.GEOMETRY_TORUS = 0x7c; -GameLib.Component.GEOMETRY_TORUS_KNOT = 0x7d; -GameLib.Component.GEOMETRY_TUBE = 0x7e; -GameLib.Component.GEOMETRY_WIREFRAME = 0x7f; +GameLib.Component.GEOMETRY_NORMAL = 0x69; +GameLib.Component.GEOMETRY_NORMAL_BOX = 0x6a; +GameLib.Component.GEOMETRY_NORMAL_CIRCLE = 0x6b; +GameLib.Component.GEOMETRY_NORMAL_CONE = 0x6c; +GameLib.Component.GEOMETRY_NORMAL_CYLINDER = 0x6d; +GameLib.Component.GEOMETRY_NORMAL_DODECAHEDRON = 0x6e; +GameLib.Component.GEOMETRY_NORMAL_EDGES = 0x6f; +GameLib.Component.GEOMETRY_NORMAL_EXTRUDE = 0x70; +GameLib.Component.GEOMETRY_NORMAL_ICOSAHEDRON = 0x71; +GameLib.Component.GEOMETRY_NORMAL_LATHE = 0x72; +GameLib.Component.GEOMETRY_NORMAL_OCTAHEDRON = 0x73; +GameLib.Component.GEOMETRY_NORMAL_PARAMETRIC = 0x74; +GameLib.Component.GEOMETRY_NORMAL_PLANE = 0x75; +GameLib.Component.GEOMETRY_NORMAL_POLYHEDRON = 0x76; +GameLib.Component.GEOMETRY_NORMAL_RING = 0x77; +GameLib.Component.GEOMETRY_NORMAL_SHAPE = 0x78; +GameLib.Component.GEOMETRY_NORMAL_SPHERE = 0x79; +GameLib.Component.GEOMETRY_NORMAL_TETRAHEDRON = 0x7a; +GameLib.Component.GEOMETRY_NORMAL_TEXT = 0x7b; +GameLib.Component.GEOMETRY_NORMAL_TORUS = 0x7c; +GameLib.Component.GEOMETRY_NORMAL_TORUS_KNOT = 0x7d; +GameLib.Component.GEOMETRY_NORMAL_TUBE = 0x7e; +GameLib.Component.GEOMETRY_NORMAL_WIREFRAME = 0x7f; -GameLib.Component.BUFFER_GEOMETRY = 0x80; -GameLib.Component.BUFFER_GEOMETRY_BOX = 0x81; -GameLib.Component.BUFFER_GEOMETRY_CIRCLE = 0x82; -GameLib.Component.BUFFER_GEOMETRY_CONE = 0x83; -GameLib.Component.BUFFER_GEOMETRY_CYLINDER = 0x84; -GameLib.Component.BUFFER_GEOMETRY_DODECAHEDRON = 0x85; -GameLib.Component.BUFFER_GEOMETRY_EXTRUDE = 0x86; -GameLib.Component.BUFFER_GEOMETRY_ICOSAHEDRON = 0x87; -GameLib.Component.BUFFER_GEOMETRY_LATHE = 0x88; -GameLib.Component.BUFFER_GEOMETRY_OCTAHEDRON = 0x89; -GameLib.Component.BUFFER_GEOMETRY_PARAMETRIC = 0x8a; -GameLib.Component.BUFFER_GEOMETRY_PLANE = 0x8b; -GameLib.Component.BUFFER_GEOMETRY_POLYHEDRON = 0x8c; -GameLib.Component.BUFFER_GEOMETRY_RING = 0x8d; -GameLib.Component.BUFFER_GEOMETRY_SHAPE = 0x8e; -GameLib.Component.BUFFER_GEOMETRY_SPHERE = 0x8f; -GameLib.Component.BUFFER_GEOMETRY_TETRAHEDRON = 0x90; -GameLib.Component.BUFFER_GEOMETRY_TEXT = 0x91; -GameLib.Component.BUFFER_GEOMETRY_TORUS = 0x92; -GameLib.Component.BUFFER_GEOMETRY_TORUS_KNOT = 0x93; -GameLib.Component.BUFFER_GEOMETRY_TUBE = 0x94; +GameLib.Component.GEOMETRY_BUFFER = 0x80; +GameLib.Component.GEOMETRY_BUFFER_BOX = 0x81; +GameLib.Component.GEOMETRY_BUFFER_CIRCLE = 0x82; +GameLib.Component.GEOMETRY_BUFFER_CONE = 0x83; +GameLib.Component.GEOMETRY_BUFFER_CYLINDER = 0x84; +GameLib.Component.GEOMETRY_BUFFER_DODECAHEDRON = 0x85; +GameLib.Component.GEOMETRY_BUFFER_EXTRUDE = 0x86; +GameLib.Component.GEOMETRY_BUFFER_ICOSAHEDRON = 0x87; +GameLib.Component.GEOMETRY_BUFFER_LATHE = 0x88; +GameLib.Component.GEOMETRY_BUFFER_OCTAHEDRON = 0x89; +GameLib.Component.GEOMETRY_BUFFER_PARAMETRIC = 0x8a; +GameLib.Component.GEOMETRY_BUFFER_PLANE = 0x8b; +GameLib.Component.GEOMETRY_BUFFER_POLYHEDRON = 0x8c; +GameLib.Component.GEOMETRY_BUFFER_RING = 0x8d; +GameLib.Component.GEOMETRY_BUFFER_SHAPE = 0x8e; +GameLib.Component.GEOMETRY_BUFFER_SPHERE = 0x8f; +GameLib.Component.GEOMETRY_BUFFER_TETRAHEDRON = 0x90; +GameLib.Component.GEOMETRY_BUFFER_TEXT = 0x91; +GameLib.Component.GEOMETRY_BUFFER_TORUS = 0x92; +GameLib.Component.GEOMETRY_BUFFER_TORUS_KNOT = 0x93; +GameLib.Component.GEOMETRY_BUFFER_TUBE = 0x94; -GameLib.Component.CURVE = 0x95; -GameLib.Component.CURVE_PATH = 0x96; -GameLib.Component.CURVE_PATH_D2 = 0x97; -GameLib.Component.CURVE_PATH_D2_SHAPE = 0x98; -GameLib.Component.BOX3 = 0x99; -GameLib.Component.DRAW_RANGE = 0x9a; -GameLib.Component.GROUP = 0x9b; +GameLib.Component.GEOMETRY = 0x95; -GameLib.Component.MAX_COMPONENTS = 0x9c; +GameLib.Component.CURVE = 0x96; +GameLib.Component.CURVE_PATH = 0x97; +GameLib.Component.CURVE_PATH_D2 = 0x98; +GameLib.Component.CURVE_PATH_D2_SHAPE = 0x99; +GameLib.Component.BOX3 = 0x9a; +GameLib.Component.DRAW_RANGE = 0x9b; +GameLib.Component.GROUP = 0x9c; + +GameLib.Component.MAX_COMPONENTS = 0x9d; GameLib.Component.GRAPHICS_RUNTIME = 0x1; GameLib.Component.PHYSICS_RUNTIME = 0x2; @@ -1035,306 +1037,312 @@ GameLib.Component.GetComponentInfo = function(number) { apiConstructor : GameLib.D3.API.Material.Phong }; case 0x69 : return { + name : 'GameLib.D3.Geometry.Normal', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal, + apiConstructor : GameLib.D3.API.Geometry.Normal + }; + case 0x6a : return { + name : 'GameLib.D3.Geometry.Normal.Box', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Box, + apiConstructor : GameLib.D3.API.Geometry.Normal.Box + }; + case 0x6b : return { + name : 'GameLib.D3.Geometry.Normal.Circle', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Circle, + apiConstructor : GameLib.D3.API.Geometry.Normal.Circle + }; + case 0x6c : return { + name : 'GameLib.D3.Geometry.Normal.Cone', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Cone, + apiConstructor : GameLib.D3.API.Geometry.Normal.Cone + }; + case 0x6d : return { + name : 'GameLib.D3.Geometry.Normal.Cylinder', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Cylinder, + apiConstructor : GameLib.D3.API.Geometry.Normal.Cylinder + }; + case 0x6e : return { + name : 'GameLib.D3.Geometry.Normal.Dodecahedron', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Dodecahedron, + apiConstructor : GameLib.D3.API.Geometry.Normal.Dodecahedron + }; + case 0x6f : return { + name : 'GameLib.D3.Geometry.Normal.Edges', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Edges, + apiConstructor : GameLib.D3.API.Geometry.Normal.Edges + }; + case 0x70 : return { + name : 'GameLib.D3.Geometry.Normal.Extrude', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Extrude, + apiConstructor : GameLib.D3.API.Geometry.Normal.Extrude + }; + case 0x71 : return { + name : 'GameLib.D3.Geometry.Normal.Icosahedron', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Icosahedron, + apiConstructor : GameLib.D3.API.Geometry.Normal.Icosahedron + }; + case 0x72 : return { + name : 'GameLib.D3.Geometry.Normal.Lathe', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Lathe, + apiConstructor : GameLib.D3.API.Geometry.Normal.Lathe + }; + case 0x73 : return { + name : 'GameLib.D3.Geometry.Normal.Octahedron', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Octahedron, + apiConstructor : GameLib.D3.API.Geometry.Normal.Octahedron + }; + case 0x74 : return { + name : 'GameLib.D3.Geometry.Normal.Parametric', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Parametric, + apiConstructor : GameLib.D3.API.Geometry.Normal.Parametric + }; + case 0x75 : return { + name : 'GameLib.D3.Geometry.Normal.Plane', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Plane, + apiConstructor : GameLib.D3.API.Geometry.Normal.Plane + }; + case 0x76 : return { + name : 'GameLib.D3.Geometry.Normal.Polyhedron', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Polyhedron, + apiConstructor : GameLib.D3.API.Geometry.Normal.Polyhedron + }; + case 0x77 : return { + name : 'GameLib.D3.Geometry.Normal.Ring', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Ring, + apiConstructor : GameLib.D3.API.Geometry.Normal.Ring + }; + case 0x78 : return { + name : 'GameLib.D3.Geometry.Normal.Shape', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Shape, + apiConstructor : GameLib.D3.API.Geometry.Normal.Shape + }; + case 0x79 : return { + name : 'GameLib.D3.Geometry.Normal.Sphere', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Sphere, + apiConstructor : GameLib.D3.API.Geometry.Normal.Sphere + }; + case 0x7a : return { + name : 'GameLib.D3.Geometry.Normal.Tetrahedron', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Tetrahedron, + apiConstructor : GameLib.D3.API.Geometry.Normal.Tetrahedron + }; + case 0x7b : return { + name : 'GameLib.D3.Geometry.Normal.Text', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Text, + apiConstructor : GameLib.D3.API.Geometry.Normal.Text + }; + case 0x7c : return { + name : 'GameLib.D3.Geometry.Normal.Torus', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Torus, + apiConstructor : GameLib.D3.API.Geometry.Normal.Torus + }; + case 0x7d : return { + name : 'GameLib.D3.Geometry.Normal.TorusKnot', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.TorusKnot, + apiConstructor : GameLib.D3.API.Geometry.Normal.TorusKnot + }; + case 0x7e : return { + name : 'GameLib.D3.Geometry.Normal.Tube', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Tube, + apiConstructor : GameLib.D3.API.Geometry.Normal.Tube + }; + case 0x7f : return { + name : 'GameLib.D3.Geometry.Normal.Wireframe', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Normal.Wireframe, + apiConstructor : GameLib.D3.API.Geometry.Normal.Wireframe + }; + case 0x80 : return { + name : 'GameLib.D3.Geometry.Buffer', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer, + apiConstructor : GameLib.D3.API.Geometry.Buffer + }; + case 0x81 : return { + name : 'GameLib.D3.Geometry.Buffer.Box', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.Box, + apiConstructor : GameLib.D3.API.Geometry.Buffer.Box + }; + case 0x82 : return { + name : 'GameLib.D3.Geometry.Buffer.Circle', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.Circle, + apiConstructor : GameLib.D3.API.Geometry.Buffer.Circle + }; + case 0x83 : return { + name : 'GameLib.D3.Geometry.Buffer.Cone', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.Cone, + apiConstructor : GameLib.D3.API.Geometry.Buffer.Cone + }; + case 0x84 : return { + name : 'GameLib.D3.Geometry.Buffer.Cylinder', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.Cylinder, + apiConstructor : GameLib.D3.API.Geometry.Buffer.Cylinder + }; + case 0x85 : return { + name : 'GameLib.D3.Geometry.Buffer.Dodecahedron', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.Dodecahedron, + apiConstructor : GameLib.D3.API.Geometry.Buffer.Dodecahedron + }; + case 0x86 : return { + name : 'GameLib.D3.Geometry.Buffer.Extrude', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.Extrude, + apiConstructor : GameLib.D3.API.Geometry.Buffer.Extrude + }; + case 0x87 : return { + name : 'GameLib.D3.Geometry.Buffer.Icosahedron', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.Icosahedron, + apiConstructor : GameLib.D3.API.Geometry.Buffer.Icosahedron + }; + case 0x88 : return { + name : 'GameLib.D3.Geometry.Buffer.Lathe', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.Lathe, + apiConstructor : GameLib.D3.API.Geometry.Buffer.Lathe + }; + case 0x89 : return { + name : 'GameLib.D3.Geometry.Buffer.Octahedron', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.Octahedron, + apiConstructor : GameLib.D3.API.Geometry.Buffer.Octahedron + }; + case 0x8a : return { + name : 'GameLib.D3.Geometry.Buffer.Parametric', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.Parametric, + apiConstructor : GameLib.D3.API.Geometry.Buffer.Parametric + }; + case 0x8b : return { + name : 'GameLib.D3.Geometry.Buffer.Plane', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.Plane, + apiConstructor : GameLib.D3.API.Geometry.Buffer.Plane + }; + case 0x8c : return { + name : 'GameLib.D3.Geometry.Buffer.Polyhedron', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.Polyhedron, + apiConstructor : GameLib.D3.API.Geometry.Buffer.Polyhedron + }; + case 0x8d : return { + name : 'GameLib.D3.Geometry.Buffer.Ring', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.Ring, + apiConstructor : GameLib.D3.API.Geometry.Buffer.Ring + }; + case 0x8e : return { + name : 'GameLib.D3.Geometry.Buffer.Shape', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.Shape, + apiConstructor : GameLib.D3.API.Geometry.Buffer.Shape + }; + case 0x8f : return { + name : 'GameLib.D3.Geometry.Buffer.Sphere', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.Sphere, + apiConstructor : GameLib.D3.API.Geometry.Buffer.Sphere + }; + case 0x90 : return { + name : 'GameLib.D3.Geometry.Buffer.Tetrahedron', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.Tetrahedron, + apiConstructor : GameLib.D3.API.Geometry.Buffer.Tetrahedron + }; + case 0x91 : return { + name : 'GameLib.D3.Geometry.Buffer.Text', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.Text, + apiConstructor : GameLib.D3.API.Geometry.Buffer.Text + }; + case 0x92 : return { + name : 'GameLib.D3.Geometry.Buffer.Torus', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.Torus, + apiConstructor : GameLib.D3.API.Geometry.Buffer.Torus + }; + case 0x93 : return { + name : 'GameLib.D3.Geometry.Buffer.TorusKnot', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.TorusKnot, + apiConstructor : GameLib.D3.API.Geometry.Buffer.TorusKnot + }; + case 0x94 : return { + name : 'GameLib.D3.Geometry.Buffer.Tube', + runtime : GameLib.Component.GRAPHICS_RUNTIME, + constructor : GameLib.D3.Geometry.Buffer.Tube, + apiConstructor : GameLib.D3.API.Geometry.Buffer.Tube + }; + case 0x95 : return { name : 'GameLib.D3.Geometry', runtime : GameLib.Component.GRAPHICS_RUNTIME, constructor : GameLib.D3.Geometry, apiConstructor : GameLib.D3.API.Geometry }; - case 0x6a : return { - name : 'GameLib.D3.Geometry.Box', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Box, - apiConstructor : GameLib.D3.API.Geometry.Box - }; - case 0x6b : return { - name : 'GameLib.D3.Geometry.Circle', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Circle, - apiConstructor : GameLib.D3.API.Geometry.Circle - }; - case 0x6c : return { - name : 'GameLib.D3.Geometry.Cone', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Cone, - apiConstructor : GameLib.D3.API.Geometry.Cone - }; - case 0x6d : return { - name : 'GameLib.D3.Geometry.Cylinder', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Cylinder, - apiConstructor : GameLib.D3.API.Geometry.Cylinder - }; - case 0x6e : return { - name : 'GameLib.D3.Geometry.Dodecahedron', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Dodecahedron, - apiConstructor : GameLib.D3.API.Geometry.Dodecahedron - }; - case 0x6f : return { - name : 'GameLib.D3.Geometry.Edges', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Edges, - apiConstructor : GameLib.D3.API.Geometry.Edges - }; - case 0x70 : return { - name : 'GameLib.D3.Geometry.Extrude', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Extrude, - apiConstructor : GameLib.D3.API.Geometry.Extrude - }; - case 0x71 : return { - name : 'GameLib.D3.Geometry.Icosahedron', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Icosahedron, - apiConstructor : GameLib.D3.API.Geometry.Icosahedron - }; - case 0x72 : return { - name : 'GameLib.D3.Geometry.Lathe', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Lathe, - apiConstructor : GameLib.D3.API.Geometry.Lathe - }; - case 0x73 : return { - name : 'GameLib.D3.Geometry.Octahedron', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Octahedron, - apiConstructor : GameLib.D3.API.Geometry.Octahedron - }; - case 0x74 : return { - name : 'GameLib.D3.Geometry.Parametric', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Parametric, - apiConstructor : GameLib.D3.API.Geometry.Parametric - }; - case 0x75 : return { - name : 'GameLib.D3.Geometry.Plane', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Plane, - apiConstructor : GameLib.D3.API.Geometry.Plane - }; - case 0x76 : return { - name : 'GameLib.D3.Geometry.Polyhedron', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Polyhedron, - apiConstructor : GameLib.D3.API.Geometry.Polyhedron - }; - case 0x77 : return { - name : 'GameLib.D3.Geometry.Ring', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Ring, - apiConstructor : GameLib.D3.API.Geometry.Ring - }; - case 0x78 : return { - name : 'GameLib.D3.Geometry.Shape', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Shape, - apiConstructor : GameLib.D3.API.Geometry.Shape - }; - case 0x79 : return { - name : 'GameLib.D3.Geometry.Sphere', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Sphere, - apiConstructor : GameLib.D3.API.Geometry.Sphere - }; - case 0x7a : return { - name : 'GameLib.D3.Geometry.Tetrahedron', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Tetrahedron, - apiConstructor : GameLib.D3.API.Geometry.Tetrahedron - }; - case 0x7b : return { - name : 'GameLib.D3.Geometry.Text', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Text, - apiConstructor : GameLib.D3.API.Geometry.Text - }; - case 0x7c : return { - name : 'GameLib.D3.Geometry.Torus', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Torus, - apiConstructor : GameLib.D3.API.Geometry.Torus - }; - case 0x7d : return { - name : 'GameLib.D3.Geometry.TorusKnot', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.TorusKnot, - apiConstructor : GameLib.D3.API.Geometry.TorusKnot - }; - case 0x7e : return { - name : 'GameLib.D3.Geometry.Tube', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Tube, - apiConstructor : GameLib.D3.API.Geometry.Tube - }; - case 0x7f : return { - name : 'GameLib.D3.Geometry.Wireframe', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.Geometry.Wireframe, - apiConstructor : GameLib.D3.API.Geometry.Wireframe - }; - case 0x80 : return { - name : 'GameLib.D3.BufferGeometry', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry, - apiConstructor : GameLib.D3.API.BufferGeometry - }; - case 0x81 : return { - name : 'GameLib.D3.BufferGeometry.Box', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.Box, - apiConstructor : GameLib.D3.API.BufferGeometry.Box - }; - case 0x82 : return { - name : 'GameLib.D3.BufferGeometry.Circle', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.Circle, - apiConstructor : GameLib.D3.API.BufferGeometry.Circle - }; - case 0x83 : return { - name : 'GameLib.D3.BufferGeometry.Cone', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.Cone, - apiConstructor : GameLib.D3.API.BufferGeometry.Cone - }; - case 0x84 : return { - name : 'GameLib.D3.BufferGeometry.Cylinder', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.Cylinder, - apiConstructor : GameLib.D3.API.BufferGeometry.Cylinder - }; - case 0x85 : return { - name : 'GameLib.D3.BufferGeometry.Dodecahedron', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.Dodecahedron, - apiConstructor : GameLib.D3.API.BufferGeometry.Dodecahedron - }; - case 0x86 : return { - name : 'GameLib.D3.BufferGeometry.Extrude', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.Extrude, - apiConstructor : GameLib.D3.API.BufferGeometry.Extrude - }; - case 0x87 : return { - name : 'GameLib.D3.BufferGeometry.Icosahedron', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.Icosahedron, - apiConstructor : GameLib.D3.API.BufferGeometry.Icosahedron - }; - case 0x88 : return { - name : 'GameLib.D3.BufferGeometry.Lathe', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.Lathe, - apiConstructor : GameLib.D3.API.BufferGeometry.Lathe - }; - case 0x89 : return { - name : 'GameLib.D3.BufferGeometry.Octahedron', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.Octahedron, - apiConstructor : GameLib.D3.API.BufferGeometry.Octahedron - }; - case 0x8a : return { - name : 'GameLib.D3.BufferGeometry.Parametric', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.Parametric, - apiConstructor : GameLib.D3.API.BufferGeometry.Parametric - }; - case 0x8b : return { - name : 'GameLib.D3.BufferGeometry.Plane', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.Plane, - apiConstructor : GameLib.D3.API.BufferGeometry.Plane - }; - case 0x8c : return { - name : 'GameLib.D3.BufferGeometry.Polyhedron', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.Polyhedron, - apiConstructor : GameLib.D3.API.BufferGeometry.Polyhedron - }; - case 0x8d : return { - name : 'GameLib.D3.BufferGeometry.Ring', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.Ring, - apiConstructor : GameLib.D3.API.BufferGeometry.Ring - }; - case 0x8e : return { - name : 'GameLib.D3.BufferGeometry.Shape', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.Shape, - apiConstructor : GameLib.D3.API.BufferGeometry.Shape - }; - case 0x8f : return { - name : 'GameLib.D3.BufferGeometry.Sphere', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.Sphere, - apiConstructor : GameLib.D3.API.BufferGeometry.Sphere - }; - case 0x90 : return { - name : 'GameLib.D3.BufferGeometry.Tetrahedron', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.Tetrahedron, - apiConstructor : GameLib.D3.API.BufferGeometry.Tetrahedron - }; - case 0x91 : return { - name : 'GameLib.D3.BufferGeometry.Text', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.Text, - apiConstructor : GameLib.D3.API.BufferGeometry.Text - }; - case 0x92 : return { - name : 'GameLib.D3.BufferGeometry.Torus', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.Torus, - apiConstructor : GameLib.D3.API.BufferGeometry.Torus - }; - case 0x93 : return { - name : 'GameLib.D3.BufferGeometry.TorusKnot', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.TorusKnot, - apiConstructor : GameLib.D3.API.BufferGeometry.TorusKnot - }; - case 0x94 : return { - name : 'GameLib.D3.BufferGeometry.Tube', - runtime : GameLib.Component.GRAPHICS_RUNTIME, - constructor : GameLib.D3.BufferGeometry.Tube, - apiConstructor : GameLib.D3.API.BufferGeometry.Tube - }; - case 0x95 : return { + case 0x96 : return { name : 'GameLib.Curve', runtime : GameLib.Component.GRAPHICS_RUNTIME, constructor : GameLib.Curve, apiConstructor : GameLib.API.Curve }; - case 0x96 : return { + case 0x97 : return { name : 'GameLib.Curve.Path', runtime : GameLib.Component.GRAPHICS_RUNTIME, constructor : GameLib.Curve.Path, apiConstructor : GameLib.API.Curve.Path }; - case 0x97 : return { + case 0x98 : return { name : 'GameLib.Curve.Path.D2', runtime : GameLib.Component.GRAPHICS_RUNTIME, constructor : GameLib.Curve.Path.D2, apiConstructor : GameLib.API.Curve.Path.D2 }; - case 0x98 : return { + case 0x99 : return { name : 'GameLib.Curve.Path.D2.Shape', runtime : GameLib.Component.GRAPHICS_RUNTIME, constructor : GameLib.Curve.Path.D2.Shape, apiConstructor : GameLib.API.Curve.Path.D2.Shape }; - case 0x99 : return { + case 0x9a : return { name : 'GameLib.Box3', runtime : GameLib.Component.GRAPHICS_RUNTIME, constructor : GameLib.Box3, apiConstructor : GameLib.API.Box3 }; - case 0x9a : return { + case 0x9b : return { name : 'GameLib.DrawRange', runtime : GameLib.Component.GRAPHICS_RUNTIME, constructor : GameLib.DrawRange, apiConstructor : GameLib.API.DrawRange }; - case 0x9b : return { + case 0x9c : return { name : 'GameLib.Group', runtime : GameLib.Component.GRAPHICS_RUNTIME, constructor : GameLib.Group, diff --git a/src/game-lib-box3.js b/src/game-lib-box3.js index 9f22b95..818667a 100644 --- a/src/game-lib-box3.js +++ b/src/game-lib-box3.js @@ -32,6 +32,18 @@ GameLib.Box3 = function ( apiBox3.max ); + this.min = new GameLib.Vector3( + this.implementation, + this.min, + this + ); + + this.max = new GameLib.Vector3( + this.implementation, + this.max, + this + ); + this.createInstance(); }; diff --git a/src/game-lib-d3-api-buffer-geometry-0.js b/src/game-lib-d3-api-buffer-geometry-0.js deleted file mode 100644 index ecaa4f5..0000000 --- a/src/game-lib-d3-api-buffer-geometry-0.js +++ /dev/null @@ -1,269 +0,0 @@ -/** - * GameLib.D3.API.BufferGeometry - * @param id - * @param name - * @param bufferGeometryType - * @param parentEntity - * @param faces - * @param vertices - * @param colors - * @param attributes - * @param boundingBox - * @param boundingSphere - * @param drawRange - * @param groups - * @param index - * @param morphAttributes - * @constructor - */ -GameLib.D3.API.BufferGeometry = function( - id, - name, - bufferGeometryType, - parentEntity, - faces, - vertices, - colors, - attributes, - boundingBox, - boundingSphere, - drawRange, - groups, - index, - morphAttributes -) { - if (GameLib.Utils.UndefinedOrNull(id)) { - id = GameLib.Utils.RandomId(); - } - this.id = id; - - if (GameLib.Utils.UndefinedOrNull(bufferGeometryType)) { - bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_NONE; - } - this.bufferGeometryType = bufferGeometryType; - - if (GameLib.Utils.UndefinedOrNull(name)) { - - switch (this.bufferGeometryType) { - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_NONE : - name = 'BufferGeometry'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_BOX : - name = 'BufferGeometry Box'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CIRCLE : - name = 'BufferGeometry Circle'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CONE : - name = 'BufferGeometry Cone'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CYLINDER : - name = 'BufferGeometry Cylinder'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_DODECAHEDRON : - name = 'BufferGeometry Dodecahedron'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_EXTRUDE : - name = 'BufferGeometry Extrude'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_ICOSAHEDRON : - name = 'BufferGeometry Icosahedron'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_LATHE : - name = 'BufferGeometry Lathe'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_OCTAHEDRON : - name = 'BufferGeometry Octahedron'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PARAMETRIC : - name = 'BufferGeometry Parametric'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PLANE : - name = 'BufferGeometry Plane'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_POLYHEDRON : - name = 'BufferGeometry Polyhedron'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_RING : - name = 'BufferGeometry Ring'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SHAPE : - name = 'BufferGeometry Shape'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SPHERE : - name = 'BufferGeometry Sphere'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TETRAHEDRON : - name = 'BufferGeometry Tetrahedron'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TEXT : - name = 'BufferGeometry Text'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS : - name = 'BufferGeometry Torus'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS_KNOT : - name = 'BufferGeometry Torus Knot'; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TUBE : - name = 'BufferGeometry Tube'; - break; - default : - console.warn('no nice name for geometry'); - name = 'BufferGeometry'; - } - - name += ' (' + id + ')'; - } - this.name = name; - - if (GameLib.Utils.UndefinedOrNull(attributes)) { - attributes = []; - } - this.attributes = attributes; - - if (GameLib.Utils.UndefinedOrNull(boundingBox)) { - boundingBox = new GameLib.API.Box3(); - } - this.boundingBox = boundingBox; - - if (GameLib.Utils.UndefinedOrNull(boundingSphere)) { - boundingSphere = new GameLib.API.Sphere(); - } - this.boundingSphere = boundingSphere; - - if (GameLib.Utils.UndefinedOrNull(groups)) { - groups = []; - } - this.groups = groups; - - if (GameLib.Utils.UndefinedOrNull(index)) { - index = null; - } - this.index = index; - - if (GameLib.Utils.UndefinedOrNull(morphAttributes)) { - morphAttributes = null; - } - this.morphAttributes = morphAttributes; - - if (GameLib.Utils.UndefinedOrNull(faces)) { - faces = []; - } - this.faces = faces; - - if (GameLib.Utils.UndefinedOrNull(vertices)) { - vertices = []; - } - this.vertices = vertices; - - GameLib.API.Component.call( - this, - GameLib.D3.API.BufferGeometry.GetComponentType(this.bufferGeometryType), - parentEntity - ); -}; - -GameLib.D3.API.BufferGeometry.prototype = Object.create(GameLib.API.Component.prototype); -GameLib.D3.API.BufferGeometry.prototype.constructor = GameLib.D3.API.BufferGeometry; - -GameLib.D3.API.BufferGeometry.GetComponentType = function(bufferGeometryType) { - - var componentType = null; - - switch (bufferGeometryType) { - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_NONE : - componentType = GameLib.Component.BUFFER_GEOMETRY; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_BOX : - componentType = GameLib.Component.BUFFER_GEOMETRY_BOX; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CIRCLE : - componentType = GameLib.Component.BUFFER_GEOMETRY_CIRCLE; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CONE : - componentType = GameLib.Component.BUFFER_GEOMETRY_CONE; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CYLINDER : - componentType = GameLib.Component.BUFFER_GEOMETRY_CYLINDER; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_DODECAHEDRON : - componentType = GameLib.Component.BUFFER_GEOMETRY_DODECAHEDRON; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_EXTRUDE : - componentType = GameLib.Component.BUFFER_GEOMETRY_EXTRUDE; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_ICOSAHEDRON : - componentType = GameLib.Component.BUFFER_GEOMETRY_ICOSAHEDRON; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_LATHE : - componentType = GameLib.Component.BUFFER_GEOMETRY_LATHE; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_OCTAHEDRON : - componentType = GameLib.Component.BUFFER_GEOMETRY_OCTAHEDRON; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PARAMETRIC: - componentType = GameLib.Component.BUFFER_GEOMETRY_PARAMETRIC; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PLANE : - componentType = GameLib.Component.BUFFER_GEOMETRY_PLANE; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_POLYHEDRON : - componentType = GameLib.Component.BUFFER_GEOMETRY_POLYHEDRON; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_RING: - componentType = GameLib.Component.BUFFER_GEOMETRY_RING; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SHAPE : - componentType = GameLib.Component.BUFFER_GEOMETRY_SHAPE; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SPHERE : - componentType = GameLib.Component.BUFFER_GEOMETRY_SPHERE; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TETRAHEDRON : - componentType = GameLib.Component.BUFFER_GEOMETRY_TETRAHEDRON; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TEXT : - componentType = GameLib.Component.BUFFER_GEOMETRY_TEXT; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS : - componentType = GameLib.Component.BUFFER_GEOMETRY_TORUS; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS_KNOT : - componentType = GameLib.Component.BUFFER_GEOMETRY_TORUS_KNOT; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TUBE : - componentType = GameLib.Component.BUFFER_GEOMETRY_TUBE; - break; - default: - throw new Error('unhandled geometry type: ' + bufferGeometryType); - } - - return componentType; -}; - -/** - * BufferGeometry Type - * @type {number} - */ -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_NONE = 0x1; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_BOX = 0x2; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CIRCLE = 0x3; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CONE = 0x4; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CYLINDER = 0x5; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_DODECAHEDRON = 0x6; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_EXTRUDE = 0x7; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_ICOSAHEDRON = 0x8; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_LATHE = 0x9; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_OCTAHEDRON = 0xa; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PARAMETRIC = 0xb; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PLANE = 0xc; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_POLYHEDRON = 0xd; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_RING = 0xe; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SHAPE = 0xf; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SPHERE = 0x10; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TETRAHEDRON = 0x11; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TEXT = 0x12; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS = 0x13; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS_KNOT = 0x14; -GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TUBE = 0x15; diff --git a/src/game-lib-d3-api-buffer-geometry-box.js b/src/game-lib-d3-api-buffer-geometry-box.js deleted file mode 100644 index 2cd72b5..0000000 --- a/src/game-lib-d3-api-buffer-geometry-box.js +++ /dev/null @@ -1,81 +0,0 @@ -/** - * GameLib.D3.API.BufferGeometry.Box - * @param apiBufferGeometry - * @param width - * @param height - * @param depth - * @param widthSegments - * @param heightSegments - * @param depthSegments - * @constructor - */ -GameLib.D3.API.BufferGeometry.Box = function( - apiBufferGeometry, - width, - height, - depth, - widthSegments, - heightSegments, - depthSegments -) { - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_BOX - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_BOX; - } - - if (GameLib.Utils.UndefinedOrNull(width)) { - width = 1; - } - this.width = width; - - if (GameLib.Utils.UndefinedOrNull(height)) { - height = 1; - } - this.height = height; - - if (GameLib.Utils.UndefinedOrNull(depth)) { - depth = 1; - } - this.depth = depth; - - if (GameLib.Utils.UndefinedOrNull(widthSegments)) { - widthSegments = 1; - } - this.widthSegments = widthSegments; - - if (GameLib.Utils.UndefinedOrNull(heightSegments)) { - heightSegments = 1; - } - this.heightSegments = heightSegments; - - if (GameLib.Utils.UndefinedOrNull(depthSegments)) { - depthSegments = 1; - } - this.depthSegments = depthSegments; - - GameLib.D3.API.BufferGeometry.call( - this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes - ); -}; - -GameLib.D3.API.BufferGeometry.Box.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.Box.prototype.constructor = GameLib.D3.API.BufferGeometry.Box; diff --git a/src/game-lib-d3-api-buffer-geometry-circle.js b/src/game-lib-d3-api-buffer-geometry-circle.js deleted file mode 100644 index 810f89e..0000000 --- a/src/game-lib-d3-api-buffer-geometry-circle.js +++ /dev/null @@ -1,67 +0,0 @@ -/** - * GameLib.D3.API.BufferGeometry.Circle - * @param apiBufferGeometry - * @param radius - * @param segments - * @param thetaStart - * @param thetaLength - * @constructor - */ -GameLib.D3.API.BufferGeometry.Circle = function( - apiBufferGeometry, - radius, - segments, - thetaStart, - thetaLength -) { - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CIRCLE - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CIRCLE; - } - - if (GameLib.Utils.UndefinedOrNull(radius)) { - radius = 1; - } - this.radius = radius; - - if (GameLib.Utils.UndefinedOrNull(segments)) { - segments = 8; - } - this.segments = segments; - - if (GameLib.Utils.UndefinedOrNull(thetaStart)) { - thetaStart = 0; - } - this.thetaStart = thetaStart; - - if (GameLib.Utils.UndefinedOrNull(thetaLength)) { - thetaLength = Math.PI * 2; - } - this.thetaLength = thetaLength; - - GameLib.D3.API.BufferGeometry.call( - this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes - ); -}; - -GameLib.D3.API.BufferGeometry.Circle.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.Circle.prototype.constructor = GameLib.D3.API.BufferGeometry.Circle; diff --git a/src/game-lib-d3-api-buffer-geometry-cone.js b/src/game-lib-d3-api-buffer-geometry-cone.js deleted file mode 100644 index 52491c2..0000000 --- a/src/game-lib-d3-api-buffer-geometry-cone.js +++ /dev/null @@ -1,88 +0,0 @@ -/** - * GameLib.D3.API.BufferGeometry.Cone - * @param apiBufferGeometry - * @param radius - * @param height - * @param radialSegments - * @param heightSegments - * @param openEnded - * @param thetaStart - * @param thetaLength - * @constructor - */ -GameLib.D3.API.BufferGeometry.Cone = function( - apiBufferGeometry, - radius, - height, - radialSegments, - heightSegments, - openEnded, - thetaStart, - thetaLength -) { - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CONE - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CONE; - } - - if (GameLib.Utils.UndefinedOrNull(radius)) { - radius = 1; - } - this.radius = radius; - - if (GameLib.Utils.UndefinedOrNull(height)) { - height = 100; - } - this.height = height; - - if (GameLib.Utils.UndefinedOrNull(radialSegments)) { - radialSegments = 8; - } - this.radialSegments = radialSegments; - - if (GameLib.Utils.UndefinedOrNull(heightSegments)) { - heightSegments = 1; - } - this.heightSegments = heightSegments; - - if (GameLib.Utils.UndefinedOrNull(openEnded)) { - openEnded = false; - } - this.openEnded = openEnded; - - if (GameLib.Utils.UndefinedOrNull(thetaStart)) { - thetaStart = 0; - } - this.thetaStart = thetaStart; - - if (GameLib.Utils.UndefinedOrNull(thetaLength)) { - thetaLength = Math.PI * 2; - } - this.thetaLength = thetaLength; - - GameLib.D3.API.BufferGeometry.call( - this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes - ); -}; - -GameLib.D3.API.BufferGeometry.Cone.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.Cone.prototype.constructor = GameLib.D3.API.BufferGeometry.Cone; diff --git a/src/game-lib-d3-api-buffer-geometry-dodecahedron.js b/src/game-lib-d3-api-buffer-geometry-dodecahedron.js deleted file mode 100644 index 3a2f1ae..0000000 --- a/src/game-lib-d3-api-buffer-geometry-dodecahedron.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * GameLib.D3.API.BufferGeometry.Dodecahedron - * @param apiBufferGeometry - * @param radius - * @param detail - * @constructor - */ -GameLib.D3.API.BufferGeometry.Dodecahedron = function( - apiBufferGeometry, - radius, - detail -) { - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_DODECAHEDRON - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_DODECAHEDRON; - } - - if (GameLib.Utils.UndefinedOrNull(radius)) { - radius = 1; - } - this.radius = radius; - - if (GameLib.Utils.UndefinedOrNull(detail)) { - detail = 0; - } - this.detail = detail; - - GameLib.D3.API.BufferGeometry.call( - this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes - ); -}; - -GameLib.D3.API.BufferGeometry.Dodecahedron.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.Dodecahedron.prototype.constructor = GameLib.D3.API.BufferGeometry.Dodecahedron; diff --git a/src/game-lib-d3-api-buffer-geometry-icosahedron.js b/src/game-lib-d3-api-buffer-geometry-icosahedron.js deleted file mode 100644 index e6bda3b..0000000 --- a/src/game-lib-d3-api-buffer-geometry-icosahedron.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * GameLib.D3.API.BufferGeometry.Icosahedron - * @param apiBufferGeometry - * @param radius - * @param detail - * @constructor - */ -GameLib.D3.API.BufferGeometry.Icosahedron = function( - apiBufferGeometry, - radius, - detail -) { - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_ICOSAHEDRON - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_ICOSAHEDRON; - } - - if (GameLib.Utils.UndefinedOrNull(radius)) { - radius = 1; - } - this.radius = radius; - - if (GameLib.Utils.UndefinedOrNull(detail)) { - detail = 0; - } - this.detail = detail; - - GameLib.D3.API.BufferGeometry.call( - this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes - ); -}; - -GameLib.D3.API.BufferGeometry.Icosahedron.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.Icosahedron.prototype.constructor = GameLib.D3.API.BufferGeometry.Icosahedron; diff --git a/src/game-lib-d3-api-buffer-geometry-lathe.js b/src/game-lib-d3-api-buffer-geometry-lathe.js deleted file mode 100644 index 4c87412..0000000 --- a/src/game-lib-d3-api-buffer-geometry-lathe.js +++ /dev/null @@ -1,67 +0,0 @@ -/** - * GameLib.D3.API.BufferGeometry.Lathe - * @param apiBufferGeometry - * @param points [GameLib.Vector2] - * @param segments - * @param phiStart - * @param phiLength - * @constructor - */ -GameLib.D3.API.BufferGeometry.Lathe = function( - apiBufferGeometry, - points, - segments, - phiStart, - phiLength -) { - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_LATHE - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_LATHE; - } - - if (GameLib.Utils.UndefinedOrNull(points)) { - points = []; - } - this.points = points; - - if (GameLib.Utils.UndefinedOrNull(segments)) { - segments = 12; - } - this.segments = segments; - - if (GameLib.Utils.UndefinedOrNull(phiStart)) { - phiStart = 0; - } - this.phiStart = phiStart; - - if (GameLib.Utils.UndefinedOrNull(phiLength)) { - phiLength = Math.PI * 2; - } - this.phiLength = phiLength; - - GameLib.D3.API.BufferGeometry.call( - this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes - ); -}; - -GameLib.D3.API.BufferGeometry.Lathe.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.Lathe.prototype.constructor = GameLib.D3.API.BufferGeometry.Lathe; diff --git a/src/game-lib-d3-api-buffer-geometry-octahedron.js b/src/game-lib-d3-api-buffer-geometry-octahedron.js deleted file mode 100644 index e1ed3f2..0000000 --- a/src/game-lib-d3-api-buffer-geometry-octahedron.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * GameLib.D3.API.BufferGeometry.Octahedron - * @param apiBufferGeometry - * @param radius - * @param detail - * @constructor - */ -GameLib.D3.API.BufferGeometry.Octahedron = function( - apiBufferGeometry, - radius, - detail -) { - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_OCTAHEDRON - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_OCTAHEDRON; - } - - if (GameLib.Utils.UndefinedOrNull(radius)) { - radius = 1; - } - this.radius = radius; - - if (GameLib.Utils.UndefinedOrNull(detail)) { - detail = 0; - } - this.detail = detail; - - GameLib.D3.API.BufferGeometry.call( - this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes - ); -}; - -GameLib.D3.API.BufferGeometry.Octahedron.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.Octahedron.prototype.constructor = GameLib.D3.API.BufferGeometry.Octahedron; diff --git a/src/game-lib-d3-api-buffer-geometry-parametric.js b/src/game-lib-d3-api-buffer-geometry-parametric.js deleted file mode 100644 index 82adb9d..0000000 --- a/src/game-lib-d3-api-buffer-geometry-parametric.js +++ /dev/null @@ -1,60 +0,0 @@ -/** - * GameLib.D3.API.BufferGeometry.Parametric - * @param apiBufferGeometry - * @param generatorFn(u,v) => returns Vector3, u and v is values between 0 and 1 - * @param slices - * @param stacks - * @constructor - */ -GameLib.D3.API.BufferGeometry.Parametric = function( - apiBufferGeometry, - generatorFn, - slices, - stacks -) { - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PARAMETRIC - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PARAMETRIC; - } - - if (GameLib.Utils.UndefinedOrNull(generatorFn)) { - generatorFn = ''; - } - this.generatorFn = generatorFn; - - if (GameLib.Utils.UndefinedOrNull(slices)) { - slices = 20; - } - this.slices = slices; - - if (GameLib.Utils.UndefinedOrNull(stacks)) { - stacks = 20; - } - this.stacks = stacks; - - GameLib.D3.API.BufferGeometry.call( - this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes - ); -}; - -GameLib.D3.API.BufferGeometry.Parametric.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.Parametric.prototype.constructor = GameLib.D3.API.BufferGeometry.Parametric; diff --git a/src/game-lib-d3-api-buffer-geometry-plane.js b/src/game-lib-d3-api-buffer-geometry-plane.js deleted file mode 100644 index eddc2c1..0000000 --- a/src/game-lib-d3-api-buffer-geometry-plane.js +++ /dev/null @@ -1,67 +0,0 @@ -/** - * GameLib.D3.API.BufferGeometry.Plane - * @param apiBufferGeometry - * @param width - * @param height - * @param widthSegments - * @param heightSegments - * @constructor - */ -GameLib.D3.API.BufferGeometry.Plane = function( - apiBufferGeometry, - width, - height, - widthSegments, - heightSegments -) { - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PLANE - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_PLANE; - } - - if (GameLib.Utils.UndefinedOrNull(width)) { - width = 1; - } - this.width = width; - - if (GameLib.Utils.UndefinedOrNull(height)) { - height = 1; - } - this.height = height; - - if (GameLib.Utils.UndefinedOrNull(widthSegments)) { - widthSegments = 1; - } - this.widthSegments = widthSegments; - - if (GameLib.Utils.UndefinedOrNull(heightSegments)) { - heightSegments = 1; - } - this.heightSegments = heightSegments; - - GameLib.D3.API.BufferGeometry.call( - this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes - ); -}; - -GameLib.D3.API.BufferGeometry.Plane.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.Plane.prototype.constructor = GameLib.D3.API.BufferGeometry.Plane; diff --git a/src/game-lib-d3-api-buffer-geometry-polyhedron.js b/src/game-lib-d3-api-buffer-geometry-polyhedron.js deleted file mode 100644 index a624e15..0000000 --- a/src/game-lib-d3-api-buffer-geometry-polyhedron.js +++ /dev/null @@ -1,67 +0,0 @@ -/** - * GameLib.D3.API.BufferGeometry.Polyhedron - * @param apiBufferGeometry - * @param vertices - * @param indices - * @param radius - * @param detail - * @constructor - */ -GameLib.D3.API.BufferGeometry.Polyhedron = function( - apiBufferGeometry, - vertices, - indices, - radius, - detail -) { - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_POLYHEDRON - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_POLYHEDRON; - } - - if (GameLib.Utils.UndefinedOrNull(vertices)) { - vertices = []; - } - this.vertices = vertices; - - if (GameLib.Utils.UndefinedOrNull(indices)) { - indices = 1; - } - this.indices = indices; - - if (GameLib.Utils.UndefinedOrNull(radius)) { - radius = 5; - } - this.radius = radius; - - if (GameLib.Utils.UndefinedOrNull(detail)) { - detail = 0; - } - this.detail = detail; - - GameLib.D3.API.BufferGeometry.call( - this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes - ); -}; - -GameLib.D3.API.BufferGeometry.Polyhedron.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.Polyhedron.prototype.constructor = GameLib.D3.API.BufferGeometry.Polyhedron; diff --git a/src/game-lib-d3-api-buffer-geometry-ring.js b/src/game-lib-d3-api-buffer-geometry-ring.js deleted file mode 100644 index a09004d..0000000 --- a/src/game-lib-d3-api-buffer-geometry-ring.js +++ /dev/null @@ -1,81 +0,0 @@ -/** - * GameLib.D3.API.BufferGeometry.Ring - * @param apiBufferGeometry - * @param innerRadius - * @param outerRadius - * @param thetaSegments - * @param phiSegments - * @param thetaStart - * @param thetaLength - * @constructor - */ -GameLib.D3.API.BufferGeometry.Ring = function( - apiBufferGeometry, - innerRadius, - outerRadius, - thetaSegments, - phiSegments, - thetaStart, - thetaLength -) { - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_RING - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_RING; - } - - if (GameLib.Utils.UndefinedOrNull(innerRadius)) { - innerRadius = 0.5; - } - this.innerRadius = innerRadius; - - if (GameLib.Utils.UndefinedOrNull(outerRadius)) { - outerRadius = 1; - } - this.outerRadius = outerRadius; - - if (GameLib.Utils.UndefinedOrNull(thetaSegments)) { - thetaSegments = 8; - } - this.thetaSegments = thetaSegments; - - if (GameLib.Utils.UndefinedOrNull(phiSegments)) { - phiSegments = 8; - } - this.phiSegments = phiSegments; - - if (GameLib.Utils.UndefinedOrNull(thetaStart)) { - thetaStart = 0; - } - this.thetaStart = thetaStart; - - if (GameLib.Utils.UndefinedOrNull(thetaLength)) { - thetaLength = Math.PI * 2; - } - this.thetaLength = thetaLength; - - GameLib.D3.API.BufferGeometry.call( - this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes - ); -}; - -GameLib.D3.API.BufferGeometry.Ring.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.Ring.prototype.constructor = GameLib.D3.API.BufferGeometry.Ring; diff --git a/src/game-lib-d3-api-buffer-geometry-shape.js b/src/game-lib-d3-api-buffer-geometry-shape.js deleted file mode 100644 index 7484d2f..0000000 --- a/src/game-lib-d3-api-buffer-geometry-shape.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * GameLib.D3.API.BufferGeometry.Shape - * @param apiBufferGeometry - * @param shapes - * @param curveSegments - * @constructor - */ -GameLib.D3.API.BufferGeometry.Shape = function( - apiBufferGeometry, - shapes, - curveSegments -) { - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SHAPE - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SHAPE; - } - - if (GameLib.Utils.UndefinedOrNull(shapes)) { - shapes = []; - } - this.shapes = shapes; - - if (GameLib.Utils.UndefinedOrNull(curveSegments)) { - curveSegments = 12; - } - this.curveSegments = curveSegments; - - GameLib.D3.API.BufferGeometry.call( - this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes - ); -}; - -GameLib.D3.API.BufferGeometry.Shape.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.Shape.prototype.constructor = GameLib.D3.API.BufferGeometry.Shape; diff --git a/src/game-lib-d3-api-buffer-geometry-sphere.js b/src/game-lib-d3-api-buffer-geometry-sphere.js deleted file mode 100644 index 0f8ea64..0000000 --- a/src/game-lib-d3-api-buffer-geometry-sphere.js +++ /dev/null @@ -1,88 +0,0 @@ -/** - * GameLib.D3.API.BufferGeometry.Sphere - * @param apiBufferGeometry - * @param radius - * @param widthSegments - * @param heightSegments - * @param phiStart - * @param phiLength - * @param thetaStart - * @param thetaLength - * @constructor - */ -GameLib.D3.API.BufferGeometry.Sphere = function( - apiBufferGeometry, - radius, - widthSegments, - heightSegments, - phiStart, - phiLength, - thetaStart, - thetaLength -) { - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SPHERE - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SPHERE; - } - - if (GameLib.Utils.UndefinedOrNull(radius)) { - radius = 1; - } - this.radius = radius; - - if (GameLib.Utils.UndefinedOrNull(widthSegments)) { - widthSegments = 8; - } - this.widthSegments = widthSegments; - - if (GameLib.Utils.UndefinedOrNull(heightSegments)) { - heightSegments = 6; - } - this.heightSegments = heightSegments; - - if (GameLib.Utils.UndefinedOrNull(phiStart)) { - phiStart = 0; - } - this.phiStart = phiStart; - - if (GameLib.Utils.UndefinedOrNull(phiLength)) { - phiLength = Math.PI * 2; - } - this.phiLength = phiLength; - - if (GameLib.Utils.UndefinedOrNull(thetaStart)) { - thetaStart = 0; - } - this.thetaStart = thetaStart; - - if (GameLib.Utils.UndefinedOrNull(thetaLength)) { - thetaLength = Math.PI * 2; - } - this.thetaLength = thetaLength; - - GameLib.D3.API.BufferGeometry.call( - this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes - ); -}; - -GameLib.D3.API.BufferGeometry.Sphere.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.Sphere.prototype.constructor = GameLib.D3.API.BufferGeometry.Sphere; diff --git a/src/game-lib-d3-api-buffer-geometry-tetrahedron.js b/src/game-lib-d3-api-buffer-geometry-tetrahedron.js deleted file mode 100644 index ba76bf4..0000000 --- a/src/game-lib-d3-api-buffer-geometry-tetrahedron.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * GameLib.D3.API.BufferGeometry.Tetrahedron - * @param apiBufferGeometry - * @param radius - * @param detail - * @constructor - */ -GameLib.D3.API.BufferGeometry.Tetrahedron = function( - apiBufferGeometry, - radius, - detail -) { - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TETRAHEDRON - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TETRAHEDRON; - } - - if (GameLib.Utils.UndefinedOrNull(radius)) { - radius = 1; - } - this.radius = radius; - - if (GameLib.Utils.UndefinedOrNull(detail)) { - detail = 0; - } - this.detail = detail; - - GameLib.D3.API.BufferGeometry.call( - this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes - ); -}; - -GameLib.D3.API.BufferGeometry.Tetrahedron.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.Tetrahedron.prototype.constructor = GameLib.D3.API.BufferGeometry.Tetrahedron; diff --git a/src/game-lib-d3-api-buffer-geometry-torus-knot.js b/src/game-lib-d3-api-buffer-geometry-torus-knot.js deleted file mode 100644 index 6ccf28a..0000000 --- a/src/game-lib-d3-api-buffer-geometry-torus-knot.js +++ /dev/null @@ -1,81 +0,0 @@ -/** - * GameLib.D3.API.BufferGeometry.TorusKnot - * @param apiBufferGeometry - * @param radius - * @param tube - * @param radialSegments - * @param tubularSegments - * @param p - * @param q - * @constructor - */ -GameLib.D3.API.BufferGeometry.TorusKnot = function( - apiBufferGeometry, - radius, - tube, - radialSegments, - tubularSegments, - p, - q -) { - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS_KNOT - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS_KNOT; - } - - if (GameLib.Utils.UndefinedOrNull(radius)) { - radius = 1; - } - this.radius = radius; - - if (GameLib.Utils.UndefinedOrNull(tube)) { - tube = 0.4; - } - this.tube = tube; - - if (GameLib.Utils.UndefinedOrNull(radialSegments)) { - radialSegments = 8; - } - this.radialSegments = radialSegments; - - if (GameLib.Utils.UndefinedOrNull(tubularSegments)) { - tubularSegments = 64; - } - this.tubularSegments = tubularSegments; - - if (GameLib.Utils.UndefinedOrNull(p)) { - p = 2; - } - this.p = p; - - if (GameLib.Utils.UndefinedOrNull(q)) { - q = 3; - } - this.q = q; - - GameLib.D3.API.BufferGeometry.call( - this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes - ); -}; - -GameLib.D3.API.BufferGeometry.TorusKnot.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.TorusKnot.prototype.constructor = GameLib.D3.API.BufferGeometry.TorusKnot; diff --git a/src/game-lib-d3-api-buffer-geometry-torus.js b/src/game-lib-d3-api-buffer-geometry-torus.js deleted file mode 100644 index 3b48941..0000000 --- a/src/game-lib-d3-api-buffer-geometry-torus.js +++ /dev/null @@ -1,74 +0,0 @@ -/** - * GameLib.D3.API.BufferGeometry.Torus - * @param apiBufferGeometry - * @param radius - * @param tube - * @param radialSegments - * @param tubularSegments - * @param arc - * @constructor - */ -GameLib.D3.API.BufferGeometry.Torus = function( - apiBufferGeometry, - radius, - tube, - radialSegments, - tubularSegments, - arc -) { - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TORUS; - } - - if (GameLib.Utils.UndefinedOrNull(radius)) { - radius = 1; - } - this.radius = radius; - - if (GameLib.Utils.UndefinedOrNull(tube)) { - tube = 0.4; - } - this.tube = tube; - - if (GameLib.Utils.UndefinedOrNull(radialSegments)) { - radialSegments = 8; - } - this.radialSegments = radialSegments; - - if (GameLib.Utils.UndefinedOrNull(tubularSegments)) { - tubularSegments = 6; - } - this.tubularSegments = tubularSegments; - - if (GameLib.Utils.UndefinedOrNull(arc)) { - arc = Math.PI * 2; - } - this.arc = arc; - - GameLib.D3.API.BufferGeometry.call( - this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes - ); -}; - -GameLib.D3.API.BufferGeometry.Torus.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.Torus.prototype.constructor = GameLib.D3.API.BufferGeometry.Torus; diff --git a/src/game-lib-d3-api-buffer-geometry-tube.js b/src/game-lib-d3-api-buffer-geometry-tube.js deleted file mode 100644 index 2a96d49..0000000 --- a/src/game-lib-d3-api-buffer-geometry-tube.js +++ /dev/null @@ -1,74 +0,0 @@ -/** - * GameLib.D3.API.BufferGeometry.Tube - * @param apiBufferGeometry - * @param path - * @param tubularSegments - * @param radius - * @param radialSegments - * @param closed - * @constructor - */ -GameLib.D3.API.BufferGeometry.Tube = function( - apiBufferGeometry, - path, - tubularSegments, - radius, - radialSegments, - closed -) { - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TUBE - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TUBE; - } - - if (GameLib.Utils.UndefinedOrNull(path)) { - path = null; - } - this.path = path; - - if (GameLib.Utils.UndefinedOrNull(tubularSegments)) { - tubularSegments = 64; - } - this.tubularSegments = tubularSegments; - - if (GameLib.Utils.UndefinedOrNull(radius)) { - radius = 1; - } - this.radius = radius; - - if (GameLib.Utils.UndefinedOrNull(radialSegments)) { - radialSegments = 8; - } - this.radialSegments = radialSegments; - - if (GameLib.Utils.UndefinedOrNull(closed)) { - closed = false; - } - this.closed = closed; - - GameLib.D3.API.BufferGeometry.call( - this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes - ); -}; - -GameLib.D3.API.BufferGeometry.Tube.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.Tube.prototype.constructor = GameLib.D3.API.BufferGeometry.Tube; diff --git a/src/game-lib-d3-api-geometry-a.js b/src/game-lib-d3-api-geometry-a.js index 5353d38..ce53047 100644 --- a/src/game-lib-d3-api-geometry-a.js +++ b/src/game-lib-d3-api-geometry-a.js @@ -1,20 +1,22 @@ /** - * GameLib.D3.API.GeometryBase + * GameLib.D3.API.Geometry * @param id * @param name * @param geometryType * @param parentEntity + * @param parentMesh * @param boundingBox * @param boundingSphere * @param faces * @param vertices * @constructor */ -GameLib.D3.API.GeometryBase = function( +GameLib.D3.API.Geometry = function( id, name, geometryType, parentEntity, + parentMesh, boundingBox, boundingSphere, faces, @@ -26,81 +28,144 @@ GameLib.D3.API.GeometryBase = function( this.id = id; if (GameLib.Utils.UndefinedOrNull(geometryType)) { - geometryType = GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_BASE; + geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NONE; } this.geometryType = geometryType; if (GameLib.Utils.UndefinedOrNull(name)) { switch (this.geometryType) { - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_NORMAL : + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL : name = 'Geometry'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_BOX : - name = 'Geometry Box'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_BOX : + name = 'Geometry Normal Box'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_CIRCLE : - name = 'Geometry Circle'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CIRCLE : + name = 'Geometry Normal Circle'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_CONE : - name = 'Geometry Cone'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CONE : + name = 'Geometry Normal Cone'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_CYLINDER : - name = 'Geometry Cylinder'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CYLINDER : + name = 'Geometry Normal Cylinder'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_DODECAHEDRON : - name = 'Geometry Dodecahedron'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_DODECAHEDRON : + name = 'Geometry Normal Dodecahedron'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_EDGES : - name = 'Geometry Edges'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EDGES : + name = 'Geometry Normal Edges'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_EXTRUDE : - name = 'Geometry Extrude'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EXTRUDE : + name = 'Geometry Normal Extrude'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_ICOSAHEDRON : - name = 'Geometry Icosahedron'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_ICOSAHEDRON : + name = 'Geometry Normal Icosahedron'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_LATHE : - name = 'Geometry Lathe'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_LATHE : + name = 'Geometry Normal Lathe'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_OCTAHEDRON : - name = 'Geometry Octahedron'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_OCTAHEDRON : + name = 'Geometry Normal Octahedron'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_PARAMETRIC : - name = 'Geometry Parametric'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_PARAMETRIC : + name = 'Geometry Normal Parametric'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_PLANE : - name = 'Geometry Plane'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_PLANE : + name = 'Geometry Normal Plane'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_POLYHEDRON : - name = 'Geometry Polyhedron'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_POLYHEDRON : + name = 'Geometry Normal Polyhedron'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_RING : - name = 'Geometry Ring'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_RING : + name = 'Geometry Normal Ring'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_SHAPE : - name = 'Geometry Shape'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SHAPE : + name = 'Geometry Normal Shape'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_SPHERE : - name = 'Geometry Sphere'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SPHERE : + name = 'Geometry Normal Sphere'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_TETRAHEDRON : - name = 'Geometry Tetrahedron'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TETRAHEDRON : + name = 'Geometry Normal Tetrahedron'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_TEXT : - name = 'Geometry Text'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TEXT : + name = 'Geometry Normal Text'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_TORUS : - name = 'Geometry Torus'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TORUS : + name = 'Geometry Normal Torus'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_TORUS_KNOT : - name = 'Geometry Torus Knot'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TORUS_KNOT : + name = 'Geometry Normal Torus Knot'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_TUBE : - name = 'Geometry Tube'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TUBE : + name = 'Geometry Normal Tube'; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_WIREFRAME : - name = 'Geometry Wireframe'; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_WIREFRAME : + name = 'Geometry Normal Wireframe'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER : + name = 'Geometry Buffer'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_BOX : + name = 'Geometry Buffer Box'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CIRCLE : + name = 'Geometry Buffer Circle'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CONE : + name = 'Geometry Buffer Cone'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CYLINDER : + name = 'Geometry Buffer Cylinder'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_DODECAHEDRON : + name = 'Geometry Buffer Dodecahedron'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_EXTRUDE : + name = 'Geometry Buffer Extrude'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_ICOSAHEDRON : + name = 'Geometry Buffer Icosahedron'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_LATHE : + name = 'Geometry Buffer Lathe'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_OCTAHEDRON : + name = 'Geometry Buffer Octahedron'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PARAMETRIC : + name = 'Geometry Buffer Parametric'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PLANE : + name = 'Geometry Buffer Plane'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_POLYHEDRON : + name = 'Geometry Buffer Polyhedron'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_RING : + name = 'Geometry Buffer Ring'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SHAPE : + name = 'Geometry Buffer Shape'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SPHERE : + name = 'Geometry Buffer Sphere'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TETRAHEDRON : + name = 'Geometry Buffer Tetrahedron'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TEXT : + name = 'Geometry Buffer Text'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS : + name = 'Geometry Buffer Torus'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS_KNOT : + name = 'Geometry Buffer Torus Knot'; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TUBE : + name = 'Geometry Buffer Tube'; break; default : console.warn('no nice name for geometry'); @@ -111,6 +176,11 @@ GameLib.D3.API.GeometryBase = function( } this.name = name; + if (GameLib.Utils.UndefinedOrNull(parentMesh)) { + parentMesh = null; + } + this.parentMesh = parentMesh; + if (GameLib.Utils.UndefinedOrNull(boundingBox)) { boundingBox = new GameLib.API.Box3(); } @@ -138,82 +208,145 @@ GameLib.D3.API.GeometryBase = function( ); }; -GameLib.D3.API.GeometryBase.prototype = Object.create(GameLib.API.Component.prototype); -GameLib.D3.API.GeometryBase.prototype.constructor = GameLib.D3.API.GeometryBase; +GameLib.D3.API.Geometry.prototype = Object.create(GameLib.API.Component.prototype); +GameLib.D3.API.Geometry.prototype.constructor = GameLib.D3.API.Geometry; -GameLib.D3.API.GeometryBase.GetComponentType = function(geometryType) { +GameLib.D3.API.Geometry.GetComponentType = function(geometryType) { var componentType = null; switch (geometryType) { - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_NORMAL : - componentType = GameLib.Component.GEOMETRY; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL : + componentType = GameLib.Component.GEOMETRY_NORMAL; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_BOX : - componentType = GameLib.Component.GEOMETRY_BOX; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_BOX : + componentType = GameLib.Component.GEOMETRY_NORMAL_BOX; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_CIRCLE : - componentType = GameLib.Component.GEOMETRY_CIRCLE; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CIRCLE : + componentType = GameLib.Component.GEOMETRY_NORMAL_CIRCLE; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_CONE : - componentType = GameLib.Component.GEOMETRY_CONE; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CONE : + componentType = GameLib.Component.GEOMETRY_NORMAL_CONE; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_CYLINDER : - componentType = GameLib.Component.GEOMETRY_CYLINDER; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CYLINDER : + componentType = GameLib.Component.GEOMETRY_NORMAL_CYLINDER; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_DODECAHEDRON : - componentType = GameLib.Component.GEOMETRY_DODECAHEDRON; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_DODECAHEDRON : + componentType = GameLib.Component.GEOMETRY_NORMAL_DODECAHEDRON; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_EDGES : - componentType = GameLib.Component.GEOMETRY_EDGES; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EDGES : + componentType = GameLib.Component.GEOMETRY_NORMAL_EDGES; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_EXTRUDE : - componentType = GameLib.Component.GEOMETRY_EXTRUDE; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EXTRUDE : + componentType = GameLib.Component.GEOMETRY_NORMAL_EXTRUDE; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_ICOSAHEDRON : - componentType = GameLib.Component.GEOMETRY_ICOSAHEDRON; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_ICOSAHEDRON : + componentType = GameLib.Component.GEOMETRY_NORMAL_ICOSAHEDRON; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_LATHE : - componentType = GameLib.Component.GEOMETRY_LATHE; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_LATHE : + componentType = GameLib.Component.GEOMETRY_NORMAL_LATHE; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_OCTAHEDRON : - componentType = GameLib.Component.GEOMETRY_OCTAHEDRON; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_OCTAHEDRON : + componentType = GameLib.Component.GEOMETRY_NORMAL_OCTAHEDRON; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_PARAMETRIC : - componentType = GameLib.Component.GEOMETRY_PARAMETRIC; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_PARAMETRIC : + componentType = GameLib.Component.GEOMETRY_NORMAL_PARAMETRIC; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_PLANE : - componentType = GameLib.Component.GEOMETRY_PLANE; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_PLANE : + componentType = GameLib.Component.GEOMETRY_NORMAL_PLANE; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_POLYHEDRON : - componentType = GameLib.Component.GEOMETRY_POLYHEDRON; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_POLYHEDRON : + componentType = GameLib.Component.GEOMETRY_NORMAL_POLYHEDRON; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_RING : - componentType = GameLib.Component.GEOMETRY_RING; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_RING : + componentType = GameLib.Component.GEOMETRY_NORMAL_RING; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_SHAPE : - componentType = GameLib.Component.GEOMETRY_SHAPE; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SHAPE : + componentType = GameLib.Component.GEOMETRY_NORMAL_SHAPE; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_SPHERE : - componentType = GameLib.Component.GEOMETRY_SPHERE; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SPHERE : + componentType = GameLib.Component.GEOMETRY_NORMAL_SPHERE; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_TETRAHEDRON : - componentType = GameLib.Component.GEOMETRY_TETRAHEDRON; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TETRAHEDRON : + componentType = GameLib.Component.GEOMETRY_NORMAL_TETRAHEDRON; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_TEXT : - componentType = GameLib.Component.GEOMETRY_TEXT; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TEXT : + componentType = GameLib.Component.GEOMETRY_NORMAL_TEXT; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_TORUS : - componentType = GameLib.Component.GEOMETRY_TORUS; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TORUS : + componentType = GameLib.Component.GEOMETRY_NORMAL_TORUS; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_TORUS_KNOT : - componentType = GameLib.Component.GEOMETRY_TORUS_KNOT; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TORUS_KNOT : + componentType = GameLib.Component.GEOMETRY_NORMAL_TORUS_KNOT; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_TUBE : - componentType = GameLib.Component.GEOMETRY_TUBE; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TUBE : + componentType = GameLib.Component.GEOMETRY_NORMAL_TUBE; break; - case GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_WIREFRAME : - componentType = GameLib.Component.GEOMETRY_WIREFRAME; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_WIREFRAME : + componentType = GameLib.Component.GEOMETRY_NORMAL_WIREFRAME; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER : + componentType = GameLib.Component.GEOMETRY_BUFFER; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_BOX : + componentType = GameLib.Component.GEOMETRY_BUFFER_BOX; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CIRCLE : + componentType = GameLib.Component.GEOMETRY_BUFFER_CIRCLE; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CONE : + componentType = GameLib.Component.GEOMETRY_BUFFER_CONE; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CYLINDER : + componentType = GameLib.Component.GEOMETRY_BUFFER_CYLINDER; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_DODECAHEDRON : + componentType = GameLib.Component.GEOMETRY_BUFFER_DODECAHEDRON; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_EXTRUDE : + componentType = GameLib.Component.GEOMETRY_BUFFER_EXTRUDE; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_ICOSAHEDRON : + componentType = GameLib.Component.GEOMETRY_BUFFER_ICOSAHEDRON; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_LATHE : + componentType = GameLib.Component.GEOMETRY_BUFFER_LATHE; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_OCTAHEDRON : + componentType = GameLib.Component.GEOMETRY_BUFFER_OCTAHEDRON; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PARAMETRIC: + componentType = GameLib.Component.GEOMETRY_BUFFER_PARAMETRIC; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PLANE : + componentType = GameLib.Component.GEOMETRY_BUFFER_PLANE; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_POLYHEDRON : + componentType = GameLib.Component.GEOMETRY_BUFFER_POLYHEDRON; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_RING: + componentType = GameLib.Component.GEOMETRY_BUFFER_RING; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SHAPE : + componentType = GameLib.Component.GEOMETRY_BUFFER_SHAPE; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SPHERE : + componentType = GameLib.Component.GEOMETRY_BUFFER_SPHERE; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TETRAHEDRON : + componentType = GameLib.Component.GEOMETRY_BUFFER_TETRAHEDRON; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TEXT : + componentType = GameLib.Component.GEOMETRY_BUFFER_TEXT; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS : + componentType = GameLib.Component.GEOMETRY_BUFFER_TORUS; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS_KNOT : + componentType = GameLib.Component.GEOMETRY_BUFFER_TORUS_KNOT; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TUBE : + componentType = GameLib.Component.GEOMETRY_BUFFER_TUBE; break; default: throw new Error('unhandled geometry type: ' + geometryType); @@ -223,30 +356,51 @@ GameLib.D3.API.GeometryBase.GetComponentType = function(geometryType) { }; /** - * GeometryBase Type + * Geometry Type * @type {number} */ -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_BASE = 0x0; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_NORMAL = 0x1; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_BOX = 0x2; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_CIRCLE = 0x3; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_CONE = 0x4; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_CYLINDER = 0x5; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_DODECAHEDRON = 0x6; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_EDGES = 0x7; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_EXTRUDE = 0x8; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_ICOSAHEDRON = 0x9; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_LATHE = 0xa; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_OCTAHEDRON = 0xb; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_PARAMETRIC = 0xc; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_PLANE = 0xd; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_POLYHEDRON = 0xe; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_RING = 0xf; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_SHAPE = 0x10; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_SPHERE = 0x11; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_TETRAHEDRON = 0x12; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_TEXT = 0x13; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_TORUS = 0x14; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_TORUS_KNOT = 0x15; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_TUBE = 0x16; -GameLib.D3.API.GeometryBase.GEOMETRY_TYPE_WIREFRAME = 0x17; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NONE = 0x0; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL = 0x1; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_BOX = 0x2; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CIRCLE = 0x3; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CONE = 0x4; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CYLINDER = 0x5; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_DODECAHEDRON = 0x6; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EDGES = 0x7; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EXTRUDE = 0x8; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_ICOSAHEDRON = 0x9; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_LATHE = 0xa; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_OCTAHEDRON = 0xb; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_PARAMETRIC = 0xc; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_PLANE = 0xd; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_POLYHEDRON = 0xe; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_RING = 0xf; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SHAPE = 0x10; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SPHERE = 0x11; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TETRAHEDRON = 0x12; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TEXT = 0x13; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TORUS = 0x14; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TORUS_KNOT = 0x15; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TUBE = 0x16; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_WIREFRAME = 0x17; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER = 0x18; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_BOX = 0x19; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CIRCLE = 0x1a; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CONE = 0x1b; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CYLINDER = 0x1c; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_DODECAHEDRON = 0x1d; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_EXTRUDE = 0x1e; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_ICOSAHEDRON = 0x1f; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_LATHE = 0x20; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_OCTAHEDRON = 0x21; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PARAMETRIC = 0x22; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PLANE = 0x23; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_POLYHEDRON = 0x24; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_RING = 0x25; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SHAPE = 0x26; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SPHERE = 0x27; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TETRAHEDRON = 0x28; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TEXT = 0x29; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS = 0x2a; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS_KNOT = 0x2b; +GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TUBE = 0x2c; diff --git a/src/game-lib-d3-api-geometry-b.js b/src/game-lib-d3-api-geometry-b.js deleted file mode 100644 index cd7c7b9..0000000 --- a/src/game-lib-d3-api-geometry-b.js +++ /dev/null @@ -1,342 +0,0 @@ -/** - * GameLib.D3.API.Geometry - * @param id - * @param name - * @param geometryType - * @param parentEntity - * @param boundingBox - * @param boundingSphere - * @param colors - * @param faces - * @param lineDistances - * @param morphTargets - * @param morphNormals - * @param skinWeights - * @param skinIndices - * @param vertices - * @param verticesNeedsUpdate - * @param elementsNeedUpdate - * @param uvsNeedUpdate - * @param normalsNeedUpdate - * @param colorsNeedUpdate - * @param groupsNeedUpdate - * @param lineDistancesNeedUpdate - * @constructor - */ -GameLib.D3.API.Geometry = function( - id, - name, - geometryType, - parentEntity, - boundingBox, - boundingSphere, - colors, - faces, - lineDistances, - morphTargets, - morphNormals, - skinWeights, - skinIndices, - vertices, - verticesNeedsUpdate, - elementsNeedUpdate, - uvsNeedUpdate, - normalsNeedUpdate, - colorsNeedUpdate, - groupsNeedUpdate, - lineDistancesNeedUpdate -) { - if (GameLib.Utils.UndefinedOrNull(id)) { - id = GameLib.Utils.RandomId(); - } - this.id = id; - - if (GameLib.Utils.UndefinedOrNull(geometryType)) { - geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL; - } - this.geometryType = geometryType; - - if (GameLib.Utils.UndefinedOrNull(name)) { - - switch (this.geometryType) { - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL : - name = 'Geometry'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BOX : - name = 'Geometry Box'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_CIRCLE : - name = 'Geometry Circle'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_CONE : - name = 'Geometry Cone'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_CYLINDER : - name = 'Geometry Cylinder'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_DODECAHEDRON : - name = 'Geometry Dodecahedron'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_EDGES : - name = 'Geometry Edges'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_EXTRUDE : - name = 'Geometry Extrude'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_ICOSAHEDRON : - name = 'Geometry Icosahedron'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_LATHE : - name = 'Geometry Lathe'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_OCTAHEDRON : - name = 'Geometry Octahedron'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_PARAMETRIC : - name = 'Geometry Parametric'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_PLANE : - name = 'Geometry Plane'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_POLYHEDRON : - name = 'Geometry Polyhedron'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_RING : - name = 'Geometry Ring'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_SHAPE : - name = 'Geometry Shape'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_SPHERE : - name = 'Geometry Sphere'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TETRAHEDRON : - name = 'Geometry Tetrahedron'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TEXT : - name = 'Geometry Text'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS : - name = 'Geometry Torus'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS_KNOT : - name = 'Geometry Torus Knot'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TUBE : - name = 'Geometry Tube'; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_WIREFRAME : - name = 'Geometry Wireframe'; - break; - default : - console.warn('no nice name for geometry'); - name = 'Geometry'; - } - - name += ' (' + id + ')'; - } - this.name = name; - - if (GameLib.Utils.UndefinedOrNull(boundingBox)) { - boundingBox = new GameLib.API.Box3(); - } - this.boundingBox = boundingBox; - - if (GameLib.Utils.UndefinedOrNull(boundingSphere)) { - boundingSphere = new GameLib.API.Sphere(); - } - this.boundingSphere = boundingSphere; - - if (GameLib.Utils.UndefinedOrNull(colors)) { - colors = []; - } - this.colors = colors; - - if (GameLib.Utils.UndefinedOrNull(faces)) { - faces = []; - } - this.faces = faces; - - if (GameLib.Utils.UndefinedOrNull(lineDistances)) { - lineDistances = []; - } - this.lineDistances = lineDistances; - - if (GameLib.Utils.UndefinedOrNull(morphTargets)) { - morphTargets = []; - } - this.morphTargets = morphTargets; - - if (GameLib.Utils.UndefinedOrNull(morphNormals)) { - morphNormals = []; - } - this.morphNormals = morphNormals; - - if (GameLib.Utils.UndefinedOrNull(skinWeights)) { - skinWeights = []; - } - this.skinWeights = skinWeights; - - if (GameLib.Utils.UndefinedOrNull(skinIndices)) { - skinIndices = []; - } - this.skinIndices = skinIndices; - - if (GameLib.Utils.UndefinedOrNull(vertices)) { - vertices = []; - } - this.vertices = vertices; - - if (GameLib.Utils.UndefinedOrNull(verticesNeedsUpdate)) { - verticesNeedsUpdate = false; - } - this.verticesNeedsUpdate = verticesNeedsUpdate; - - if (GameLib.Utils.UndefinedOrNull(elementsNeedUpdate)) { - elementsNeedUpdate = false; - } - this.elementsNeedUpdate = elementsNeedUpdate; - - if (GameLib.Utils.UndefinedOrNull(uvsNeedUpdate)) { - uvsNeedUpdate = false; - } - this.uvsNeedUpdate = uvsNeedUpdate; - - if (GameLib.Utils.UndefinedOrNull(normalsNeedUpdate)) { - normalsNeedUpdate = false; - } - this.normalsNeedUpdate = normalsNeedUpdate; - - if (GameLib.Utils.UndefinedOrNull(colorsNeedUpdate)) { - colorsNeedUpdate = false; - } - this.colorsNeedUpdate = colorsNeedUpdate; - - if (GameLib.Utils.UndefinedOrNull(groupsNeedUpdate)) { - groupsNeedUpdate = false; - } - this.groupsNeedUpdate = groupsNeedUpdate; - - if (GameLib.Utils.UndefinedOrNull(lineDistancesNeedUpdate)) { - lineDistancesNeedUpdate = false; - } - this.lineDistancesNeedUpdate = lineDistancesNeedUpdate; - - GameLib.API.Component.call( - this, - GameLib.D3.API.Geometry.GetComponentType(this.geometryType), - parentEntity - ); -}; - -GameLib.D3.API.Geometry.prototype = Object.create(GameLib.API.Component.prototype); -GameLib.D3.API.Geometry.prototype.constructor = GameLib.D3.API.Geometry; - -GameLib.D3.API.Geometry.GetComponentType = function(geometryType) { - - var componentType = null; - - switch (geometryType) { - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL : - componentType = GameLib.Component.GEOMETRY; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BOX : - componentType = GameLib.Component.GEOMETRY_BOX; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_CIRCLE : - componentType = GameLib.Component.GEOMETRY_CIRCLE; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_CONE : - componentType = GameLib.Component.GEOMETRY_CONE; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_CYLINDER : - componentType = GameLib.Component.GEOMETRY_CYLINDER; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_DODECAHEDRON : - componentType = GameLib.Component.GEOMETRY_DODECAHEDRON; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_EDGES : - componentType = GameLib.Component.GEOMETRY_EDGES; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_EXTRUDE : - componentType = GameLib.Component.GEOMETRY_EXTRUDE; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_ICOSAHEDRON : - componentType = GameLib.Component.GEOMETRY_ICOSAHEDRON; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_LATHE : - componentType = GameLib.Component.GEOMETRY_LATHE; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_OCTAHEDRON : - componentType = GameLib.Component.GEOMETRY_OCTAHEDRON; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_PARAMETRIC : - componentType = GameLib.Component.GEOMETRY_PARAMETRIC; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_PLANE : - componentType = GameLib.Component.GEOMETRY_PLANE; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_POLYHEDRON : - componentType = GameLib.Component.GEOMETRY_POLYHEDRON; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_RING : - componentType = GameLib.Component.GEOMETRY_RING; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_SHAPE : - componentType = GameLib.Component.GEOMETRY_SHAPE; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_SPHERE : - componentType = GameLib.Component.GEOMETRY_SPHERE; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TETRAHEDRON : - componentType = GameLib.Component.GEOMETRY_TETRAHEDRON; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TEXT : - componentType = GameLib.Component.GEOMETRY_TEXT; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS : - componentType = GameLib.Component.GEOMETRY_TORUS; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS_KNOT : - componentType = GameLib.Component.GEOMETRY_TORUS_KNOT; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TUBE : - componentType = GameLib.Component.GEOMETRY_TUBE; - break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_WIREFRAME : - componentType = GameLib.Component.GEOMETRY_WIREFRAME; - break; - default: - throw new Error('unhandled geometry type: ' + geometryType); - } - - return componentType; -}; - -/** - * Geometry Type - * @type {number} - */ -GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL = 0x0; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_BOX = 0x1; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_CIRCLE = 0x2; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_CONE = 0x3; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_CYLINDER = 0x4; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_DODECAHEDRON = 0x5; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_EDGES = 0x6; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_EXTRUDE = 0x7; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_ICOSAHEDRON = 0x8; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_LATHE = 0x9; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_OCTAHEDRON = 0xa; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_PARAMETRIC = 0xb; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_PLANE = 0xc; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_POLYHEDRON = 0xd; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_RING = 0xe; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_SHAPE = 0xf; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_SPHERE = 0x10; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_TETRAHEDRON = 0x11; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_TEXT = 0x12; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS = 0x13; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS_KNOT = 0x14; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_TUBE = 0x15; -GameLib.D3.API.Geometry.GEOMETRY_TYPE_WIREFRAME = 0x16; diff --git a/src/game-lib-d3-api-geometry-buffer-a.js b/src/game-lib-d3-api-geometry-buffer-a.js new file mode 100644 index 0000000..5628b8f --- /dev/null +++ b/src/game-lib-d3-api-geometry-buffer-a.js @@ -0,0 +1,69 @@ +/** + * GameLib.D3.API.Geometry.Buffer + * @param apiGeometry + * @param attributes + * @param drawRange + * @param groups + * @param index + * @param morphAttributes + * @constructor + */ +GameLib.D3.API.Geometry.Buffer = function( + apiGeometry, + attributes, + drawRange, + groups, + index, + morphAttributes +) { + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER; + } + + if (GameLib.Utils.UndefinedOrNull(attributes)) { + attributes = []; + } + this.attributes = attributes; + + if (GameLib.Utils.UndefinedOrNull(groups)) { + groups = []; + } + this.groups = groups; + + if (GameLib.Utils.UndefinedOrNull(drawRange)) { + drawRange = new GameLib.API.DrawRange() + } + this.drawRange = drawRange; + + if (GameLib.Utils.UndefinedOrNull(index)) { + index = null; + } + this.index = index; + + if (GameLib.Utils.UndefinedOrNull(morphAttributes)) { + morphAttributes = null; + } + this.morphAttributes = morphAttributes; + + GameLib.D3.API.Geometry.call( + this, + apiGeometry.id, + apiGeometry.name, + apiGeometry.geometryType, + apiGeometry.parentEntity, + apiGeometry.parentMesh, + apiGeometry.boundingBox, + apiGeometry.boundingSphere, + apiGeometry.faces, + apiGeometry.vertices + ); +}; + +GameLib.D3.API.Geometry.Buffer.prototype = Object.create(GameLib.D3.API.Geometry.prototype); +GameLib.D3.API.Geometry.Buffer.prototype.constructor = GameLib.D3.API.Geometry.Buffer; diff --git a/src/game-lib-d3-api-geometry-buffer-box.js b/src/game-lib-d3-api-geometry-buffer-box.js new file mode 100644 index 0000000..a867708 --- /dev/null +++ b/src/game-lib-d3-api-geometry-buffer-box.js @@ -0,0 +1,74 @@ +/** + * GameLib.D3.API.Geometry.Buffer.Box + * @param apiGeometry + * @param width + * @param height + * @param depth + * @param widthSegments + * @param heightSegments + * @param depthSegments + * @constructor + */ +GameLib.D3.API.Geometry.Buffer.Box = function( + apiGeometry, + width, + height, + depth, + widthSegments, + heightSegments, + depthSegments +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_BOX + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_BOX; + } + + if (GameLib.Utils.UndefinedOrNull(width)) { + width = 1; + } + this.width = width; + + if (GameLib.Utils.UndefinedOrNull(height)) { + height = 1; + } + this.height = height; + + if (GameLib.Utils.UndefinedOrNull(depth)) { + depth = 1; + } + this.depth = depth; + + if (GameLib.Utils.UndefinedOrNull(widthSegments)) { + widthSegments = 1; + } + this.widthSegments = widthSegments; + + if (GameLib.Utils.UndefinedOrNull(heightSegments)) { + heightSegments = 1; + } + this.heightSegments = heightSegments; + + if (GameLib.Utils.UndefinedOrNull(depthSegments)) { + depthSegments = 1; + } + this.depthSegments = depthSegments; + + GameLib.D3.API.Geometry.Buffer.call( + this, + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes + ); +}; + +GameLib.D3.API.Geometry.Buffer.Box.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.Box.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Box; diff --git a/src/game-lib-d3-api-geometry-buffer-circle.js b/src/game-lib-d3-api-geometry-buffer-circle.js new file mode 100644 index 0000000..a7b20df --- /dev/null +++ b/src/game-lib-d3-api-geometry-buffer-circle.js @@ -0,0 +1,60 @@ +/** + * GameLib.D3.API.Geometry.Buffer.Circle + * @param apiGeometry + * @param radius + * @param segments + * @param thetaStart + * @param thetaLength + * @constructor + */ +GameLib.D3.API.Geometry.Buffer.Circle = function( + apiGeometry, + radius, + segments, + thetaStart, + thetaLength +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CIRCLE + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CIRCLE; + } + + if (GameLib.Utils.UndefinedOrNull(radius)) { + radius = 1; + } + this.radius = radius; + + if (GameLib.Utils.UndefinedOrNull(segments)) { + segments = 8; + } + this.segments = segments; + + if (GameLib.Utils.UndefinedOrNull(thetaStart)) { + thetaStart = 0; + } + this.thetaStart = thetaStart; + + if (GameLib.Utils.UndefinedOrNull(thetaLength)) { + thetaLength = Math.PI * 2; + } + this.thetaLength = thetaLength; + + GameLib.D3.API.Geometry.Buffer.call( + this, + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes + ); +}; + +GameLib.D3.API.Geometry.Buffer.Circle.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.Circle.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Circle; diff --git a/src/game-lib-d3-api-geometry-buffer-cone.js b/src/game-lib-d3-api-geometry-buffer-cone.js new file mode 100644 index 0000000..1dc4585 --- /dev/null +++ b/src/game-lib-d3-api-geometry-buffer-cone.js @@ -0,0 +1,81 @@ +/** + * GameLib.D3.API.Geometry.Buffer.Cone + * @param apiGeometry + * @param radius + * @param height + * @param radialSegments + * @param heightSegments + * @param openEnded + * @param thetaStart + * @param thetaLength + * @constructor + */ +GameLib.D3.API.Geometry.Buffer.Cone = function( + apiGeometry, + radius, + height, + radialSegments, + heightSegments, + openEnded, + thetaStart, + thetaLength +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CONE + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CONE; + } + + if (GameLib.Utils.UndefinedOrNull(radius)) { + radius = 1; + } + this.radius = radius; + + if (GameLib.Utils.UndefinedOrNull(height)) { + height = 100; + } + this.height = height; + + if (GameLib.Utils.UndefinedOrNull(radialSegments)) { + radialSegments = 8; + } + this.radialSegments = radialSegments; + + if (GameLib.Utils.UndefinedOrNull(heightSegments)) { + heightSegments = 1; + } + this.heightSegments = heightSegments; + + if (GameLib.Utils.UndefinedOrNull(openEnded)) { + openEnded = false; + } + this.openEnded = openEnded; + + if (GameLib.Utils.UndefinedOrNull(thetaStart)) { + thetaStart = 0; + } + this.thetaStart = thetaStart; + + if (GameLib.Utils.UndefinedOrNull(thetaLength)) { + thetaLength = Math.PI * 2; + } + this.thetaLength = thetaLength; + + GameLib.D3.API.Geometry.Buffer.call( + this, + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes + ); +}; + +GameLib.D3.API.Geometry.Buffer.Cone.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.Cone.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Cone; diff --git a/src/game-lib-d3-api-buffer-geometry-cylinder.js b/src/game-lib-d3-api-geometry-buffer-cylinder.js similarity index 52% rename from src/game-lib-d3-api-buffer-geometry-cylinder.js rename to src/game-lib-d3-api-geometry-buffer-cylinder.js index 5ceec66..0e4aeae 100644 --- a/src/game-lib-d3-api-buffer-geometry-cylinder.js +++ b/src/game-lib-d3-api-geometry-buffer-cylinder.js @@ -1,6 +1,6 @@ /** - * GameLib.D3.API.BufferGeometry.Cylinder - * @param apiBufferGeometry + * GameLib.D3.API.Geometry.Buffer.Cylinder + * @param apiGeometry * @param radiusTop * @param radiusBottom * @param height @@ -11,8 +11,8 @@ * @param thetaLength * @constructor */ -GameLib.D3.API.BufferGeometry.Cylinder = function( - apiBufferGeometry, +GameLib.D3.API.Geometry.Buffer.Cylinder = function( + apiGeometry, radiusTop, radiusBottom, height, @@ -23,14 +23,14 @@ GameLib.D3.API.BufferGeometry.Cylinder = function( thetaLength ) { - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CYLINDER + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CYLINDER }; } - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_CYLINDER; + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CYLINDER; } if (GameLib.Utils.UndefinedOrNull(radiusTop)) { @@ -73,23 +73,16 @@ GameLib.D3.API.BufferGeometry.Cylinder = function( } this.thetaLength = thetaLength; - GameLib.D3.API.BufferGeometry.call( + GameLib.D3.API.Geometry.Buffer.call( this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes ); }; -GameLib.D3.API.BufferGeometry.Cylinder.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.Cylinder.prototype.constructor = GameLib.D3.API.BufferGeometry.Cylinder; +GameLib.D3.API.Geometry.Buffer.Cylinder.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.Cylinder.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Cylinder; diff --git a/src/game-lib-d3-api-geometry-buffer-dodecahedron.js b/src/game-lib-d3-api-geometry-buffer-dodecahedron.js new file mode 100644 index 0000000..1bca3ed --- /dev/null +++ b/src/game-lib-d3-api-geometry-buffer-dodecahedron.js @@ -0,0 +1,46 @@ +/** + * GameLib.D3.API.Geometry.Buffer.Dodecahedron + * @param apiGeometry + * @param radius + * @param detail + * @constructor + */ +GameLib.D3.API.Geometry.Buffer.Dodecahedron = function( + apiGeometry, + radius, + detail +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_DODECAHEDRON + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_DODECAHEDRON; + } + + if (GameLib.Utils.UndefinedOrNull(radius)) { + radius = 1; + } + this.radius = radius; + + if (GameLib.Utils.UndefinedOrNull(detail)) { + detail = 0; + } + this.detail = detail; + + GameLib.D3.API.Geometry.Buffer.call( + this, + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes + ); +}; + +GameLib.D3.API.Geometry.Buffer.Dodecahedron.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.Dodecahedron.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Dodecahedron; diff --git a/src/game-lib-d3-api-buffer-geometry-extrude.js b/src/game-lib-d3-api-geometry-buffer-extrude.js similarity index 57% rename from src/game-lib-d3-api-buffer-geometry-extrude.js rename to src/game-lib-d3-api-geometry-buffer-extrude.js index b011f04..142f3d2 100644 --- a/src/game-lib-d3-api-buffer-geometry-extrude.js +++ b/src/game-lib-d3-api-geometry-buffer-extrude.js @@ -1,6 +1,6 @@ /** - * GameLib.D3.API.BufferGeometry.Extrude - * @param apiBufferGeometry + * GameLib.D3.API.Geometry.Buffer.Extrude + * @param apiGeometry * @param shapes * @param curveSegments * @param steps @@ -14,8 +14,8 @@ * @param UVGenerator * @constructor */ -GameLib.D3.API.BufferGeometry.Extrude = function( - apiBufferGeometry, +GameLib.D3.API.Geometry.Buffer.Extrude = function( + apiGeometry, shapes, curveSegments, steps, @@ -29,14 +29,14 @@ GameLib.D3.API.BufferGeometry.Extrude = function( UVGenerator ) { - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_EXTRUDE + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_EXTRUDE }; } - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_EXTRUDE; + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_EXTRUDE; } if (GameLib.Utils.UndefinedOrNull(shapes)) { @@ -89,23 +89,16 @@ GameLib.D3.API.BufferGeometry.Extrude = function( } this.UVGenerator = UVGenerator; - GameLib.D3.API.BufferGeometry.call( + GameLib.D3.API.Geometry.Buffer.call( this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes ); }; -GameLib.D3.API.BufferGeometry.Extrude.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.Extrude.prototype.constructor = GameLib.D3.API.BufferGeometry.Extrude; +GameLib.D3.API.Geometry.Buffer.Extrude.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.Extrude.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Extrude; diff --git a/src/game-lib-d3-api-geometry-buffer-icosahedron.js b/src/game-lib-d3-api-geometry-buffer-icosahedron.js new file mode 100644 index 0000000..00e8bf7 --- /dev/null +++ b/src/game-lib-d3-api-geometry-buffer-icosahedron.js @@ -0,0 +1,46 @@ +/** + * GameLib.D3.API.Geometry.Buffer.Icosahedron + * @param apiGeometry + * @param radius + * @param detail + * @constructor + */ +GameLib.D3.API.Geometry.Buffer.Icosahedron = function( + apiGeometry, + radius, + detail +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_ICOSAHEDRON + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_ICOSAHEDRON; + } + + if (GameLib.Utils.UndefinedOrNull(radius)) { + radius = 1; + } + this.radius = radius; + + if (GameLib.Utils.UndefinedOrNull(detail)) { + detail = 0; + } + this.detail = detail; + + GameLib.D3.API.Geometry.Buffer.call( + this, + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes + ); +}; + +GameLib.D3.API.Geometry.Buffer.Icosahedron.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.Icosahedron.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Icosahedron; diff --git a/src/game-lib-d3-api-geometry-buffer-lathe.js b/src/game-lib-d3-api-geometry-buffer-lathe.js new file mode 100644 index 0000000..a7ae05c --- /dev/null +++ b/src/game-lib-d3-api-geometry-buffer-lathe.js @@ -0,0 +1,60 @@ +/** + * GameLib.D3.API.Geometry.Buffer.Lathe + * @param apiGeometry + * @param points [GameLib.Vector2] (x must be larger than 0) + * @param segments + * @param phiStart + * @param phiLength + * @constructor + */ +GameLib.D3.API.Geometry.Buffer.Lathe = function( + apiGeometry, + points, + segments, + phiStart, + phiLength +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_LATHE + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_LATHE; + } + + if (GameLib.Utils.UndefinedOrNull(points)) { + points = []; + } + this.points = points; + + if (GameLib.Utils.UndefinedOrNull(segments)) { + segments = 12; + } + this.segments = segments; + + if (GameLib.Utils.UndefinedOrNull(phiStart)) { + phiStart = 0; + } + this.phiStart = phiStart; + + if (GameLib.Utils.UndefinedOrNull(phiLength)) { + phiLength = Math.PI * 2; + } + this.phiLength = phiLength; + + GameLib.D3.API.Geometry.Buffer.call( + this, + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes + ); +}; + +GameLib.D3.API.Geometry.Buffer.Lathe.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.Lathe.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Lathe; diff --git a/src/game-lib-d3-api-geometry-buffer-octahedron.js b/src/game-lib-d3-api-geometry-buffer-octahedron.js new file mode 100644 index 0000000..c3ea69b --- /dev/null +++ b/src/game-lib-d3-api-geometry-buffer-octahedron.js @@ -0,0 +1,46 @@ +/** + * GameLib.D3.API.Geometry.Buffer.Octahedron + * @param apiGeometry + * @param radius + * @param detail + * @constructor + */ +GameLib.D3.API.Geometry.Buffer.Octahedron = function( + apiGeometry, + radius, + detail +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_OCTAHEDRON + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_OCTAHEDRON; + } + + if (GameLib.Utils.UndefinedOrNull(radius)) { + radius = 1; + } + this.radius = radius; + + if (GameLib.Utils.UndefinedOrNull(detail)) { + detail = 0; + } + this.detail = detail; + + GameLib.D3.API.Geometry.Buffer.call( + this, + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes + ); +}; + +GameLib.D3.API.Geometry.Buffer.Octahedron.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.Octahedron.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Octahedron; diff --git a/src/game-lib-d3-api-geometry-buffer-parametric.js b/src/game-lib-d3-api-geometry-buffer-parametric.js new file mode 100644 index 0000000..dd14186 --- /dev/null +++ b/src/game-lib-d3-api-geometry-buffer-parametric.js @@ -0,0 +1,53 @@ +/** + * GameLib.D3.API.Geometry.Buffer.Parametric + * @param apiGeometry + * @param generatorFn(u,v) => returns Vector3, u and v is values between 0 and 1 + * @param slices + * @param stacks + * @constructor + */ +GameLib.D3.API.Geometry.Buffer.Parametric = function( + apiGeometry, + generatorFn, + slices, + stacks +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PARAMETRIC + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PARAMETRIC; + } + + if (GameLib.Utils.UndefinedOrNull(generatorFn)) { + generatorFn = ''; + } + this.generatorFn = generatorFn; + + if (GameLib.Utils.UndefinedOrNull(slices)) { + slices = 20; + } + this.slices = slices; + + if (GameLib.Utils.UndefinedOrNull(stacks)) { + stacks = 20; + } + this.stacks = stacks; + + GameLib.D3.API.Geometry.Buffer.call( + this, + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes + ); +}; + +GameLib.D3.API.Geometry.Buffer.Parametric.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.Parametric.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Parametric; diff --git a/src/game-lib-d3-api-geometry-buffer-plane.js b/src/game-lib-d3-api-geometry-buffer-plane.js new file mode 100644 index 0000000..f1c7a7a --- /dev/null +++ b/src/game-lib-d3-api-geometry-buffer-plane.js @@ -0,0 +1,60 @@ +/** + * GameLib.D3.API.Geometry.Buffer.Plane + * @param apiGeometry + * @param width + * @param height + * @param widthSegments + * @param heightSegments + * @constructor + */ +GameLib.D3.API.Geometry.Buffer.Plane = function( + apiGeometry, + width, + height, + widthSegments, + heightSegments +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PLANE + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PLANE; + } + + if (GameLib.Utils.UndefinedOrNull(width)) { + width = 1; + } + this.width = width; + + if (GameLib.Utils.UndefinedOrNull(height)) { + height = 1; + } + this.height = height; + + if (GameLib.Utils.UndefinedOrNull(widthSegments)) { + widthSegments = 1; + } + this.widthSegments = widthSegments; + + if (GameLib.Utils.UndefinedOrNull(heightSegments)) { + heightSegments = 1; + } + this.heightSegments = heightSegments; + + GameLib.D3.API.Geometry.Buffer.call( + this, + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes + ); +}; + +GameLib.D3.API.Geometry.Buffer.Plane.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.Plane.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Plane; diff --git a/src/game-lib-d3-api-geometry-buffer-polyhedron.js b/src/game-lib-d3-api-geometry-buffer-polyhedron.js new file mode 100644 index 0000000..b654990 --- /dev/null +++ b/src/game-lib-d3-api-geometry-buffer-polyhedron.js @@ -0,0 +1,60 @@ +/** + * GameLib.D3.API.Geometry.Buffer.Polyhedron + * @param apiGeometry + * @param vertices + * @param indices + * @param radius + * @param detail + * @constructor + */ +GameLib.D3.API.Geometry.Buffer.Polyhedron = function( + apiGeometry, + vertices, + indices, + radius, + detail +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_POLYHEDRON + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_POLYHEDRON; + } + + if (GameLib.Utils.UndefinedOrNull(vertices)) { + vertices = []; + } + this.vertices = vertices; + + if (GameLib.Utils.UndefinedOrNull(indices)) { + indices = 1; + } + this.indices = indices; + + if (GameLib.Utils.UndefinedOrNull(radius)) { + radius = 5; + } + this.radius = radius; + + if (GameLib.Utils.UndefinedOrNull(detail)) { + detail = 0; + } + this.detail = detail; + + GameLib.D3.API.Geometry.Buffer.call( + this, + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes + ); +}; + +GameLib.D3.API.Geometry.Buffer.Polyhedron.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.Polyhedron.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Polyhedron; diff --git a/src/game-lib-d3-api-geometry-buffer-ring.js b/src/game-lib-d3-api-geometry-buffer-ring.js new file mode 100644 index 0000000..38072b5 --- /dev/null +++ b/src/game-lib-d3-api-geometry-buffer-ring.js @@ -0,0 +1,74 @@ +/** + * GameLib.D3.API.Geometry.Buffer.Ring + * @param apiGeometry + * @param innerRadius + * @param outerRadius + * @param thetaSegments + * @param phiSegments + * @param thetaStart + * @param thetaLength + * @constructor + */ +GameLib.D3.API.Geometry.Buffer.Ring = function( + apiGeometry, + innerRadius, + outerRadius, + thetaSegments, + phiSegments, + thetaStart, + thetaLength +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_RING + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_RING; + } + + if (GameLib.Utils.UndefinedOrNull(innerRadius)) { + innerRadius = 0.5; + } + this.innerRadius = innerRadius; + + if (GameLib.Utils.UndefinedOrNull(outerRadius)) { + outerRadius = 1; + } + this.outerRadius = outerRadius; + + if (GameLib.Utils.UndefinedOrNull(thetaSegments)) { + thetaSegments = 8; + } + this.thetaSegments = thetaSegments; + + if (GameLib.Utils.UndefinedOrNull(phiSegments)) { + phiSegments = 8; + } + this.phiSegments = phiSegments; + + if (GameLib.Utils.UndefinedOrNull(thetaStart)) { + thetaStart = 0; + } + this.thetaStart = thetaStart; + + if (GameLib.Utils.UndefinedOrNull(thetaLength)) { + thetaLength = Math.PI * 2; + } + this.thetaLength = thetaLength; + + GameLib.D3.API.Geometry.Buffer.call( + this, + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes + ); +}; + +GameLib.D3.API.Geometry.Buffer.Ring.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.Ring.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Ring; diff --git a/src/game-lib-d3-api-geometry-buffer-shape.js b/src/game-lib-d3-api-geometry-buffer-shape.js new file mode 100644 index 0000000..68626ac --- /dev/null +++ b/src/game-lib-d3-api-geometry-buffer-shape.js @@ -0,0 +1,46 @@ +/** + * GameLib.D3.API.Geometry.Buffer.Shape + * @param apiGeometry + * @param shapes + * @param curveSegments + * @constructor + */ +GameLib.D3.API.Geometry.Buffer.Shape = function( + apiGeometry, + shapes, + curveSegments +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SHAPE + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SHAPE; + } + + if (GameLib.Utils.UndefinedOrNull(shapes)) { + shapes = []; + } + this.shapes = shapes; + + if (GameLib.Utils.UndefinedOrNull(curveSegments)) { + curveSegments = 12; + } + this.curveSegments = curveSegments; + + GameLib.D3.API.Geometry.Buffer.call( + this, + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes + ); +}; + +GameLib.D3.API.Geometry.Buffer.Shape.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.Shape.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Shape; diff --git a/src/game-lib-d3-api-geometry-buffer-sphere.js b/src/game-lib-d3-api-geometry-buffer-sphere.js new file mode 100644 index 0000000..95acc8a --- /dev/null +++ b/src/game-lib-d3-api-geometry-buffer-sphere.js @@ -0,0 +1,81 @@ +/** + * GameLib.D3.API.Geometry.Buffer.Sphere + * @param apiGeometry + * @param radius + * @param widthSegments + * @param heightSegments + * @param phiStart + * @param phiLength + * @param thetaStart + * @param thetaLength + * @constructor + */ +GameLib.D3.API.Geometry.Buffer.Sphere = function( + apiGeometry, + radius, + widthSegments, + heightSegments, + phiStart, + phiLength, + thetaStart, + thetaLength +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SPHERE + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SPHERE; + } + + if (GameLib.Utils.UndefinedOrNull(radius)) { + radius = 1; + } + this.radius = radius; + + if (GameLib.Utils.UndefinedOrNull(widthSegments)) { + widthSegments = 8; + } + this.widthSegments = widthSegments; + + if (GameLib.Utils.UndefinedOrNull(heightSegments)) { + heightSegments = 6; + } + this.heightSegments = heightSegments; + + if (GameLib.Utils.UndefinedOrNull(phiStart)) { + phiStart = 0; + } + this.phiStart = phiStart; + + if (GameLib.Utils.UndefinedOrNull(phiLength)) { + phiLength = Math.PI * 2; + } + this.phiLength = phiLength; + + if (GameLib.Utils.UndefinedOrNull(thetaStart)) { + thetaStart = 0; + } + this.thetaStart = thetaStart; + + if (GameLib.Utils.UndefinedOrNull(thetaLength)) { + thetaLength = Math.PI; + } + this.thetaLength = thetaLength; + + GameLib.D3.API.Geometry.Buffer.call( + this, + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes + ); +}; + +GameLib.D3.API.Geometry.Buffer.Sphere.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.Sphere.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Sphere; diff --git a/src/game-lib-d3-api-geometry-buffer-tetrahedron.js b/src/game-lib-d3-api-geometry-buffer-tetrahedron.js new file mode 100644 index 0000000..aaa0569 --- /dev/null +++ b/src/game-lib-d3-api-geometry-buffer-tetrahedron.js @@ -0,0 +1,46 @@ +/** + * GameLib.D3.API.Geometry.Buffer.Tetrahedron + * @param apiGeometry + * @param radius + * @param detail + * @constructor + */ +GameLib.D3.API.Geometry.Buffer.Tetrahedron = function( + apiGeometry, + radius, + detail +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TETRAHEDRON + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TETRAHEDRON; + } + + if (GameLib.Utils.UndefinedOrNull(radius)) { + radius = 1; + } + this.radius = radius; + + if (GameLib.Utils.UndefinedOrNull(detail)) { + detail = 0; + } + this.detail = detail; + + GameLib.D3.API.Geometry.Buffer.call( + this, + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes + ); +}; + +GameLib.D3.API.Geometry.Buffer.Tetrahedron.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.Tetrahedron.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Tetrahedron; diff --git a/src/game-lib-d3-api-buffer-geometry-text.js b/src/game-lib-d3-api-geometry-buffer-text.js similarity index 51% rename from src/game-lib-d3-api-buffer-geometry-text.js rename to src/game-lib-d3-api-geometry-buffer-text.js index bb3fa12..4a34424 100644 --- a/src/game-lib-d3-api-buffer-geometry-text.js +++ b/src/game-lib-d3-api-geometry-buffer-text.js @@ -1,6 +1,6 @@ /** - * GameLib.D3.API.BufferGeometry.Text - * @param apiBufferGeometry + * GameLib.D3.API.Geometry.Buffer.Text + * @param apiGeometry * @param text * @param font * @param size @@ -12,8 +12,8 @@ * @param bevelSegments * @constructor */ -GameLib.D3.API.BufferGeometry.Text = function( - apiBufferGeometry, +GameLib.D3.API.Geometry.Buffer.Text = function( + apiGeometry, text, font, size, @@ -25,14 +25,14 @@ GameLib.D3.API.BufferGeometry.Text = function( bevelSegments ) { - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { - apiBufferGeometry = { - bufferGeometryType: GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TEXT + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TEXT }; } - if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry.bufferGeometryType)) { - apiBufferGeometry.bufferGeometryType = GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TEXT; + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TEXT; } if (GameLib.Utils.UndefinedOrNull(text)) { @@ -46,12 +46,12 @@ GameLib.D3.API.BufferGeometry.Text = function( this.font = font; if (GameLib.Utils.UndefinedOrNull(size)) { - size = 100; + size = 10; } this.size = size; if (GameLib.Utils.UndefinedOrNull(height)) { - height = 50; + height = 5; } this.height = height; @@ -66,7 +66,7 @@ GameLib.D3.API.BufferGeometry.Text = function( this.bevelEnabled = bevelEnabled; if (GameLib.Utils.UndefinedOrNull(bevelThickness)) { - bevelThickness = 10; + bevelThickness = 1; } this.bevelThickness = bevelThickness; @@ -80,23 +80,16 @@ GameLib.D3.API.BufferGeometry.Text = function( } this.bevelSegments = bevelSegments; - GameLib.D3.API.BufferGeometry.call( + GameLib.D3.API.Geometry.Buffer.call( this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, - apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, - apiBufferGeometry.drawRange, - apiBufferGeometry.groups, - apiBufferGeometry.index, - apiBufferGeometry.morphAttributes + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes ); }; -GameLib.D3.API.BufferGeometry.Text.prototype = Object.create(GameLib.D3.API.BufferGeometry.prototype); -GameLib.D3.API.BufferGeometry.Text.prototype.constructor = GameLib.D3.API.BufferGeometry.Text; +GameLib.D3.API.Geometry.Buffer.Text.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.Text.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Text; diff --git a/src/game-lib-d3-api-geometry-buffer-torus-knot.js b/src/game-lib-d3-api-geometry-buffer-torus-knot.js new file mode 100644 index 0000000..a0d4a4b --- /dev/null +++ b/src/game-lib-d3-api-geometry-buffer-torus-knot.js @@ -0,0 +1,74 @@ +/** + * GameLib.D3.API.Geometry.Buffer.TorusKnot + * @param apiGeometry + * @param radius + * @param tube + * @param radialSegments + * @param tubularSegments + * @param p + * @param q + * @constructor + */ +GameLib.D3.API.Geometry.Buffer.TorusKnot = function( + apiGeometry, + radius, + tube, + radialSegments, + tubularSegments, + p, + q +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS_KNOT + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS_KNOT; + } + + if (GameLib.Utils.UndefinedOrNull(radius)) { + radius = 1; + } + this.radius = radius; + + if (GameLib.Utils.UndefinedOrNull(tube)) { + tube = 0.4; + } + this.tube = tube; + + if (GameLib.Utils.UndefinedOrNull(radialSegments)) { + radialSegments = 8; + } + this.radialSegments = radialSegments; + + if (GameLib.Utils.UndefinedOrNull(tubularSegments)) { + tubularSegments = 64; + } + this.tubularSegments = tubularSegments; + + if (GameLib.Utils.UndefinedOrNull(p)) { + p = 2; + } + this.p = p; + + if (GameLib.Utils.UndefinedOrNull(q)) { + q = 3; + } + this.q = q; + + GameLib.D3.API.Geometry.Buffer.call( + this, + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes + ); +}; + +GameLib.D3.API.Geometry.Buffer.TorusKnot.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.TorusKnot.prototype.constructor = GameLib.D3.API.Geometry.Buffer.TorusKnot; diff --git a/src/game-lib-d3-api-geometry-buffer-torus.js b/src/game-lib-d3-api-geometry-buffer-torus.js new file mode 100644 index 0000000..0538eda --- /dev/null +++ b/src/game-lib-d3-api-geometry-buffer-torus.js @@ -0,0 +1,67 @@ +/** + * GameLib.D3.API.Geometry.Buffer.Torus + * @param apiGeometry + * @param radius + * @param tube + * @param radialSegments + * @param tubularSegments + * @param arc + * @constructor + */ +GameLib.D3.API.Geometry.Buffer.Torus = function( + apiGeometry, + radius, + tube, + radialSegments, + tubularSegments, + arc +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS; + } + + if (GameLib.Utils.UndefinedOrNull(radius)) { + radius = 1; + } + this.radius = radius; + + if (GameLib.Utils.UndefinedOrNull(tube)) { + tube = 0.4; + } + this.tube = tube; + + if (GameLib.Utils.UndefinedOrNull(radialSegments)) { + radialSegments = 8; + } + this.radialSegments = radialSegments; + + if (GameLib.Utils.UndefinedOrNull(tubularSegments)) { + tubularSegments = 6; + } + this.tubularSegments = tubularSegments; + + if (GameLib.Utils.UndefinedOrNull(arc)) { + arc = Math.PI * 2; + } + this.arc = arc; + + GameLib.D3.API.Geometry.Buffer.call( + this, + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes + ); +}; + +GameLib.D3.API.Geometry.Buffer.Torus.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.Torus.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Torus; diff --git a/src/game-lib-d3-api-geometry-buffer-tube.js b/src/game-lib-d3-api-geometry-buffer-tube.js new file mode 100644 index 0000000..0a700b9 --- /dev/null +++ b/src/game-lib-d3-api-geometry-buffer-tube.js @@ -0,0 +1,67 @@ +/** + * GameLib.D3.API.Geometry.Buffer.Tube + * @param apiGeometry + * @param path + * @param tubularSegments + * @param radius + * @param radialSegments + * @param closed + * @constructor + */ +GameLib.D3.API.Geometry.Buffer.Tube = function( + apiGeometry, + path, + tubularSegments, + radius, + radialSegments, + closed +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TUBE + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TUBE; + } + + if (GameLib.Utils.UndefinedOrNull(path)) { + path = null; + } + this.path = path; + + if (GameLib.Utils.UndefinedOrNull(tubularSegments)) { + tubularSegments = 64; + } + this.tubularSegments = tubularSegments; + + if (GameLib.Utils.UndefinedOrNull(radius)) { + radius = 1; + } + this.radius = radius; + + if (GameLib.Utils.UndefinedOrNull(radialSegments)) { + radialSegments = 8; + } + this.radialSegments = radialSegments; + + if (GameLib.Utils.UndefinedOrNull(closed)) { + closed = false; + } + this.closed = closed; + + GameLib.D3.API.Geometry.Buffer.call( + this, + apiGeometry, + apiGeometry.attributes, + apiGeometry.drawRange, + apiGeometry.groups, + apiGeometry.index, + apiGeometry.morphAttributes + ); +}; + +GameLib.D3.API.Geometry.Buffer.Tube.prototype = Object.create(GameLib.D3.API.Geometry.Buffer.prototype); +GameLib.D3.API.Geometry.Buffer.Tube.prototype.constructor = GameLib.D3.API.Geometry.Buffer.Tube; diff --git a/src/game-lib-d3-api-geometry-dodecahedron.js b/src/game-lib-d3-api-geometry-dodecahedron.js deleted file mode 100644 index a774fee..0000000 --- a/src/game-lib-d3-api-geometry-dodecahedron.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * GameLib.D3.API.Geometry.Dodecahedron - * @param apiGeometry - * @param radius - * @param detail - * @constructor - */ -GameLib.D3.API.Geometry.Dodecahedron = function( - apiGeometry, - radius, - detail -) { - - if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { - apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_DODECAHEDRON - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_DODECAHEDRON; - } - - if (GameLib.Utils.UndefinedOrNull(radius)) { - radius = 1; - } - this.radius = radius; - - if (GameLib.Utils.UndefinedOrNull(detail)) { - detail = 0; - } - this.detail = detail; - - GameLib.D3.API.Geometry.call( - this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, - apiGeometry.lineDistancesNeedUpdate - ); -}; - -GameLib.D3.API.Geometry.Dodecahedron.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Dodecahedron.prototype.constructor = GameLib.D3.API.Geometry.Dodecahedron; diff --git a/src/game-lib-d3-api-geometry-edges.js b/src/game-lib-d3-api-geometry-edges.js deleted file mode 100644 index 4ddcac3..0000000 --- a/src/game-lib-d3-api-geometry-edges.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * GameLib.D3.API.Geometry.Edges - * @param apiGeometry - * @param geometry - * @param thresholdAngle (degrees) - * @constructor - */ -GameLib.D3.API.Geometry.Edges = function( - apiGeometry, - geometry, - thresholdAngle -) { - - if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { - apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_EDGES - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_EDGES; - } - - if (GameLib.Utils.UndefinedOrNull(geometry)) { - geometry = null; - } - this.geometry = geometry; - - if (GameLib.Utils.UndefinedOrNull(thresholdAngle)) { - thresholdAngle = 1; - } - this.thresholdAngle = thresholdAngle; - - GameLib.D3.API.Geometry.call( - this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, - apiGeometry.lineDistancesNeedUpdate - ); -}; - -GameLib.D3.API.Geometry.Edges.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Edges.prototype.constructor = GameLib.D3.API.Geometry.Edges; diff --git a/src/game-lib-d3-api-geometry-icosahedron.js b/src/game-lib-d3-api-geometry-icosahedron.js deleted file mode 100644 index a29f076..0000000 --- a/src/game-lib-d3-api-geometry-icosahedron.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * GameLib.D3.API.Geometry.Icosahedron - * @param apiGeometry - * @param radius - * @param detail - * @constructor - */ -GameLib.D3.API.Geometry.Icosahedron = function( - apiGeometry, - radius, - detail -) { - - if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { - apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_ICOSAHEDRON - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_ICOSAHEDRON; - } - - if (GameLib.Utils.UndefinedOrNull(radius)) { - radius = 1; - } - this.radius = radius; - - if (GameLib.Utils.UndefinedOrNull(detail)) { - detail = 0; - } - this.detail = detail; - - GameLib.D3.API.Geometry.call( - this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, - apiGeometry.lineDistancesNeedUpdate - ); -}; - -GameLib.D3.API.Geometry.Icosahedron.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Icosahedron.prototype.constructor = GameLib.D3.API.Geometry.Icosahedron; diff --git a/src/game-lib-d3-api-geometry-normal-a.js b/src/game-lib-d3-api-geometry-normal-a.js new file mode 100644 index 0000000..7d2c17f --- /dev/null +++ b/src/game-lib-d3-api-geometry-normal-a.js @@ -0,0 +1,125 @@ +/** + * GameLib.D3.API.Geometry + * @param apiGeometry + * @param colors + * @param lineDistances + * @param morphTargets + * @param morphNormals + * @param skinWeights + * @param skinIndices + * @param verticesNeedsUpdate + * @param elementsNeedUpdate + * @param uvsNeedUpdate + * @param normalsNeedUpdate + * @param colorsNeedUpdate + * @param groupsNeedUpdate + * @param lineDistancesNeedUpdate + * @constructor + */ +GameLib.D3.API.Geometry.Normal = function( + apiGeometry, + colors, + lineDistances, + morphTargets, + morphNormals, + skinWeights, + skinIndices, + verticesNeedsUpdate, + elementsNeedUpdate, + uvsNeedUpdate, + normalsNeedUpdate, + colorsNeedUpdate, + groupsNeedUpdate, + lineDistancesNeedUpdate +) { + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL; + } + + if (GameLib.Utils.UndefinedOrNull(colors)) { + colors = []; + } + this.colors = colors; + + if (GameLib.Utils.UndefinedOrNull(lineDistances)) { + lineDistances = []; + } + this.lineDistances = lineDistances; + + if (GameLib.Utils.UndefinedOrNull(morphTargets)) { + morphTargets = []; + } + this.morphTargets = morphTargets; + + if (GameLib.Utils.UndefinedOrNull(morphNormals)) { + morphNormals = []; + } + this.morphNormals = morphNormals; + + if (GameLib.Utils.UndefinedOrNull(skinWeights)) { + skinWeights = []; + } + this.skinWeights = skinWeights; + + if (GameLib.Utils.UndefinedOrNull(skinIndices)) { + skinIndices = []; + } + this.skinIndices = skinIndices; + + if (GameLib.Utils.UndefinedOrNull(verticesNeedsUpdate)) { + verticesNeedsUpdate = false; + } + this.verticesNeedsUpdate = verticesNeedsUpdate; + + if (GameLib.Utils.UndefinedOrNull(elementsNeedUpdate)) { + elementsNeedUpdate = false; + } + this.elementsNeedUpdate = elementsNeedUpdate; + + if (GameLib.Utils.UndefinedOrNull(uvsNeedUpdate)) { + uvsNeedUpdate = false; + } + this.uvsNeedUpdate = uvsNeedUpdate; + + if (GameLib.Utils.UndefinedOrNull(normalsNeedUpdate)) { + normalsNeedUpdate = false; + } + this.normalsNeedUpdate = normalsNeedUpdate; + + if (GameLib.Utils.UndefinedOrNull(colorsNeedUpdate)) { + colorsNeedUpdate = false; + } + this.colorsNeedUpdate = colorsNeedUpdate; + + if (GameLib.Utils.UndefinedOrNull(groupsNeedUpdate)) { + groupsNeedUpdate = false; + } + this.groupsNeedUpdate = groupsNeedUpdate; + + if (GameLib.Utils.UndefinedOrNull(lineDistancesNeedUpdate)) { + lineDistancesNeedUpdate = false; + } + this.lineDistancesNeedUpdate = lineDistancesNeedUpdate; + + GameLib.D3.API.Geometry.call( + this, + apiGeometry.id, + apiGeometry.name, + apiGeometry.geometryType, + apiGeometry.parentEntity, + apiGeometry.parentMesh, + apiGeometry.boundingBox, + apiGeometry.boundingSphere, + apiGeometry.faces, + apiGeometry.vertices + ); +}; + +GameLib.D3.API.Geometry.Normal.prototype = Object.create(GameLib.D3.API.Geometry.prototype); +GameLib.D3.API.Geometry.Normal.prototype.constructor = GameLib.D3.API.Geometry.Normal; diff --git a/src/game-lib-d3-api-geometry-box.js b/src/game-lib-d3-api-geometry-normal-box.js similarity index 61% rename from src/game-lib-d3-api-geometry-box.js rename to src/game-lib-d3-api-geometry-normal-box.js index fd46276..454d473 100644 --- a/src/game-lib-d3-api-geometry-box.js +++ b/src/game-lib-d3-api-geometry-normal-box.js @@ -1,5 +1,5 @@ /** - * GameLib.D3.API.Geometry.Box + * GameLib.D3.API.Geometry.Normal.Box * @param apiGeometry * @param width * @param height @@ -9,7 +9,7 @@ * @param depthSegments * @constructor */ -GameLib.D3.API.Geometry.Box = function( +GameLib.D3.API.Geometry.Normal.Box = function( apiGeometry, width, height, @@ -21,12 +21,12 @@ GameLib.D3.API.Geometry.Box = function( if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_BOX + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_BOX }; } if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_BOX; + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_BOX; } if (GameLib.Utils.UndefinedOrNull(width)) { @@ -59,33 +59,24 @@ GameLib.D3.API.Geometry.Box = function( } this.depthSegments = depthSegments; - GameLib.D3.API.Geometry.call( + GameLib.D3.API.Geometry.Normal.call( this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, apiGeometry.lineDistancesNeedUpdate ); }; -GameLib.D3.API.Geometry.Box.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Box.prototype.constructor = GameLib.D3.API.Geometry.Box; +GameLib.D3.API.Geometry.Normal.Box.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Box.prototype.constructor = GameLib.D3.API.Geometry.Normal.Box; diff --git a/src/game-lib-d3-api-geometry-circle.js b/src/game-lib-d3-api-geometry-normal-circle.js similarity index 54% rename from src/game-lib-d3-api-geometry-circle.js rename to src/game-lib-d3-api-geometry-normal-circle.js index 5f3b933..45894b6 100644 --- a/src/game-lib-d3-api-geometry-circle.js +++ b/src/game-lib-d3-api-geometry-normal-circle.js @@ -1,5 +1,5 @@ /** - * GameLib.D3.API.Geometry.Circle + * GameLib.D3.API.Geometry.Normal.Circle * @param apiGeometry * @param radius * @param segments @@ -7,7 +7,7 @@ * @param thetaLength * @constructor */ -GameLib.D3.API.Geometry.Circle = function( +GameLib.D3.API.Geometry.Normal.Circle = function( apiGeometry, radius, segments, @@ -17,12 +17,12 @@ GameLib.D3.API.Geometry.Circle = function( if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_CIRCLE + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CIRCLE }; } if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_CIRCLE; + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CIRCLE; } if (GameLib.Utils.UndefinedOrNull(radius)) { @@ -45,33 +45,24 @@ GameLib.D3.API.Geometry.Circle = function( } this.thetaLength = thetaLength; - GameLib.D3.API.Geometry.call( + GameLib.D3.API.Geometry.Normal.call( this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, apiGeometry.lineDistancesNeedUpdate ); }; -GameLib.D3.API.Geometry.Circle.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Circle.prototype.constructor = GameLib.D3.API.Geometry.Circle; +GameLib.D3.API.Geometry.Normal.Circle.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Circle.prototype.constructor = GameLib.D3.API.Geometry.Normal.Circle; diff --git a/src/game-lib-d3-api-geometry-cone.js b/src/game-lib-d3-api-geometry-normal-cone.js similarity index 64% rename from src/game-lib-d3-api-geometry-cone.js rename to src/game-lib-d3-api-geometry-normal-cone.js index 98ad475..09bdc4b 100644 --- a/src/game-lib-d3-api-geometry-cone.js +++ b/src/game-lib-d3-api-geometry-normal-cone.js @@ -1,5 +1,5 @@ /** - * GameLib.D3.API.Geometry.Cone + * GameLib.D3.API.Geometry.Normal.Cone * @param apiGeometry * @param radius * @param height @@ -10,7 +10,7 @@ * @param thetaLength * @constructor */ -GameLib.D3.API.Geometry.Cone = function( +GameLib.D3.API.Geometry.Normal.Cone = function( apiGeometry, radius, height, @@ -23,12 +23,12 @@ GameLib.D3.API.Geometry.Cone = function( if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_CONE + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CONE }; } if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_CONE; + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CONE; } if (GameLib.Utils.UndefinedOrNull(radius)) { @@ -66,33 +66,24 @@ GameLib.D3.API.Geometry.Cone = function( } this.thetaLength = thetaLength; - GameLib.D3.API.Geometry.call( + GameLib.D3.API.Geometry.Normal.call( this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, apiGeometry.lineDistancesNeedUpdate ); }; -GameLib.D3.API.Geometry.Cone.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Cone.prototype.constructor = GameLib.D3.API.Geometry.Cone; +GameLib.D3.API.Geometry.Normal.Cone.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Cone.prototype.constructor = GameLib.D3.API.Geometry.Normal.Cone; diff --git a/src/game-lib-d3-api-geometry-cylinder.js b/src/game-lib-d3-api-geometry-normal-cylinder.js similarity index 66% rename from src/game-lib-d3-api-geometry-cylinder.js rename to src/game-lib-d3-api-geometry-normal-cylinder.js index b2690f0..ce02cb9 100644 --- a/src/game-lib-d3-api-geometry-cylinder.js +++ b/src/game-lib-d3-api-geometry-normal-cylinder.js @@ -1,5 +1,5 @@ /** - * GameLib.D3.API.Geometry.Cylinder + * GameLib.D3.API.Geometry.Normal.Cylinder * @param apiGeometry * @param radiusTop * @param radiusBottom @@ -11,7 +11,7 @@ * @param thetaLength * @constructor */ -GameLib.D3.API.Geometry.Cylinder = function( +GameLib.D3.API.Geometry.Normal.Cylinder = function( apiGeometry, radiusTop, radiusBottom, @@ -25,12 +25,12 @@ GameLib.D3.API.Geometry.Cylinder = function( if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_CYLINDER + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CYLINDER }; } if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_CYLINDER; + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CYLINDER; } if (GameLib.Utils.UndefinedOrNull(radiusTop)) { @@ -73,33 +73,24 @@ GameLib.D3.API.Geometry.Cylinder = function( } this.thetaLength = thetaLength; - GameLib.D3.API.Geometry.call( + GameLib.D3.API.Geometry.Normal.call( this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, apiGeometry.lineDistancesNeedUpdate ); }; -GameLib.D3.API.Geometry.Cylinder.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Cylinder.prototype.constructor = GameLib.D3.API.Geometry.Cylinder; +GameLib.D3.API.Geometry.Normal.Cylinder.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Cylinder.prototype.constructor = GameLib.D3.API.Geometry.Normal.Cylinder; diff --git a/src/game-lib-d3-api-geometry-normal-dodecahedron.js b/src/game-lib-d3-api-geometry-normal-dodecahedron.js new file mode 100644 index 0000000..5bcb07e --- /dev/null +++ b/src/game-lib-d3-api-geometry-normal-dodecahedron.js @@ -0,0 +1,54 @@ +/** + * GameLib.D3.API.Geometry.Normal.Dodecahedron + * @param apiGeometry + * @param radius + * @param detail + * @constructor + */ +GameLib.D3.API.Geometry.Normal.Dodecahedron = function( + apiGeometry, + radius, + detail +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_DODECAHEDRON + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_DODECAHEDRON; + } + + if (GameLib.Utils.UndefinedOrNull(radius)) { + radius = 1; + } + this.radius = radius; + + if (GameLib.Utils.UndefinedOrNull(detail)) { + detail = 0; + } + this.detail = detail; + + GameLib.D3.API.Geometry.Normal.call( + this, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, + apiGeometry.lineDistancesNeedUpdate + ); +}; + +GameLib.D3.API.Geometry.Normal.Dodecahedron.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Dodecahedron.prototype.constructor = GameLib.D3.API.Geometry.Normal.Dodecahedron; diff --git a/src/game-lib-d3-api-geometry-normal-edges.js b/src/game-lib-d3-api-geometry-normal-edges.js new file mode 100644 index 0000000..0c27a56 --- /dev/null +++ b/src/game-lib-d3-api-geometry-normal-edges.js @@ -0,0 +1,54 @@ +/** + * GameLib.D3.API.Geometry.Normal.Edges + * @param apiGeometry + * @param geometry + * @param thresholdAngle (degrees) + * @constructor + */ +GameLib.D3.API.Geometry.Normal.Edges = function( + apiGeometry, + geometry, + thresholdAngle +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EDGES + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EDGES; + } + + if (GameLib.Utils.UndefinedOrNull(geometry)) { + geometry = null; + } + this.geometry = geometry; + + if (GameLib.Utils.UndefinedOrNull(thresholdAngle)) { + thresholdAngle = 1; + } + this.thresholdAngle = thresholdAngle; + + GameLib.D3.API.Geometry.Normal.call( + this, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, + apiGeometry.lineDistancesNeedUpdate + ); +}; + +GameLib.D3.API.Geometry.Normal.Edges.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Edges.prototype.constructor = GameLib.D3.API.Geometry.Normal.Edges; diff --git a/src/game-lib-d3-api-geometry-extrude.js b/src/game-lib-d3-api-geometry-normal-extrude.js similarity index 69% rename from src/game-lib-d3-api-geometry-extrude.js rename to src/game-lib-d3-api-geometry-normal-extrude.js index 24d203a..58182fe 100644 --- a/src/game-lib-d3-api-geometry-extrude.js +++ b/src/game-lib-d3-api-geometry-normal-extrude.js @@ -1,5 +1,5 @@ /** - * GameLib.D3.API.Geometry.Extrude + * GameLib.D3.API.Geometry.Normal.Extrude * @param apiGeometry * @param shapes * @param curveSegments @@ -14,7 +14,7 @@ * @param UVGenerator * @constructor */ -GameLib.D3.API.Geometry.Extrude = function( +GameLib.D3.API.Geometry.Normal.Extrude = function( apiGeometry, shapes, curveSegments, @@ -31,12 +31,12 @@ GameLib.D3.API.Geometry.Extrude = function( if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_EXTRUDE + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EXTRUDE }; } if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_EXTRUDE; + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EXTRUDE; } if (GameLib.Utils.UndefinedOrNull(shapes)) { @@ -89,33 +89,24 @@ GameLib.D3.API.Geometry.Extrude = function( } this.UVGenerator = UVGenerator; - GameLib.D3.API.Geometry.call( + GameLib.D3.API.Geometry.Normal.call( this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, apiGeometry.lineDistancesNeedUpdate ); }; -GameLib.D3.API.Geometry.Extrude.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Extrude.prototype.constructor = GameLib.D3.API.Geometry.Extrude; +GameLib.D3.API.Geometry.Normal.Extrude.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Extrude.prototype.constructor = GameLib.D3.API.Geometry.Normal.Extrude; diff --git a/src/game-lib-d3-api-geometry-normal-icosahedron.js b/src/game-lib-d3-api-geometry-normal-icosahedron.js new file mode 100644 index 0000000..5607dbf --- /dev/null +++ b/src/game-lib-d3-api-geometry-normal-icosahedron.js @@ -0,0 +1,54 @@ +/** + * GameLib.D3.API.Geometry.Normal.Icosahedron + * @param apiGeometry + * @param radius + * @param detail + * @constructor + */ +GameLib.D3.API.Geometry.Normal.Icosahedron = function( + apiGeometry, + radius, + detail +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_ICOSAHEDRON + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_ICOSAHEDRON; + } + + if (GameLib.Utils.UndefinedOrNull(radius)) { + radius = 1; + } + this.radius = radius; + + if (GameLib.Utils.UndefinedOrNull(detail)) { + detail = 0; + } + this.detail = detail; + + GameLib.D3.API.Geometry.Normal.call( + this, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, + apiGeometry.lineDistancesNeedUpdate + ); +}; + +GameLib.D3.API.Geometry.Normal.Icosahedron.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Icosahedron.prototype.constructor = GameLib.D3.API.Geometry.Normal.Icosahedron; diff --git a/src/game-lib-d3-api-geometry-lathe.js b/src/game-lib-d3-api-geometry-normal-lathe.js similarity index 54% rename from src/game-lib-d3-api-geometry-lathe.js rename to src/game-lib-d3-api-geometry-normal-lathe.js index 3be2aa3..88ff63d 100644 --- a/src/game-lib-d3-api-geometry-lathe.js +++ b/src/game-lib-d3-api-geometry-normal-lathe.js @@ -1,5 +1,5 @@ /** - * GameLib.D3.API.Geometry.Lathe + * GameLib.D3.API.Geometry.Normal.Lathe * @param apiGeometry * @param points [GameLib.Vector2] * @param segments @@ -7,7 +7,7 @@ * @param phiLength * @constructor */ -GameLib.D3.API.Geometry.Lathe = function( +GameLib.D3.API.Geometry.Normal.Lathe = function( apiGeometry, points, segments, @@ -17,12 +17,12 @@ GameLib.D3.API.Geometry.Lathe = function( if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_LATHE + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_LATHE }; } if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_LATHE; + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_LATHE; } if (GameLib.Utils.UndefinedOrNull(points)) { @@ -45,33 +45,24 @@ GameLib.D3.API.Geometry.Lathe = function( } this.phiLength = phiLength; - GameLib.D3.API.Geometry.call( + GameLib.D3.API.Geometry.Normal.call( this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, apiGeometry.lineDistancesNeedUpdate ); }; -GameLib.D3.API.Geometry.Lathe.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Lathe.prototype.constructor = GameLib.D3.API.Geometry.Lathe; +GameLib.D3.API.Geometry.Normal.Lathe.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Lathe.prototype.constructor = GameLib.D3.API.Geometry.Normal.Lathe; diff --git a/src/game-lib-d3-api-geometry-normal-octahedron.js b/src/game-lib-d3-api-geometry-normal-octahedron.js new file mode 100644 index 0000000..3203698 --- /dev/null +++ b/src/game-lib-d3-api-geometry-normal-octahedron.js @@ -0,0 +1,54 @@ +/** + * GameLib.D3.API.Geometry.Normal.Octahedron + * @param apiGeometry + * @param radius + * @param detail + * @constructor + */ +GameLib.D3.API.Geometry.Normal.Octahedron = function( + apiGeometry, + radius, + detail +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_OCTAHEDRON + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_OCTAHEDRON; + } + + if (GameLib.Utils.UndefinedOrNull(radius)) { + radius = 1; + } + this.radius = radius; + + if (GameLib.Utils.UndefinedOrNull(detail)) { + detail = 0; + } + this.detail = detail; + + GameLib.D3.API.Geometry.Normal.call( + this, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, + apiGeometry.lineDistancesNeedUpdate + ); +}; + +GameLib.D3.API.Geometry.Normal.Octahedron.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Octahedron.prototype.constructor = GameLib.D3.API.Geometry.Normal.Octahedron; diff --git a/src/game-lib-d3-api-geometry-parametric.js b/src/game-lib-d3-api-geometry-normal-parametric.js similarity index 50% rename from src/game-lib-d3-api-geometry-parametric.js rename to src/game-lib-d3-api-geometry-normal-parametric.js index a70bbdc..2402693 100644 --- a/src/game-lib-d3-api-geometry-parametric.js +++ b/src/game-lib-d3-api-geometry-normal-parametric.js @@ -1,12 +1,12 @@ /** - * GameLib.D3.API.Geometry.Parametric + * GameLib.D3.API.Geometry.Normal.Parametric * @param apiGeometry * @param generatorFn(u,v) => returns Vector3, u and v is values between 0 and 1 * @param slices * @param stacks * @constructor */ -GameLib.D3.API.Geometry.Parametric = function( +GameLib.D3.API.Geometry.Normal.Parametric = function( apiGeometry, generatorFn, slices, @@ -15,12 +15,12 @@ GameLib.D3.API.Geometry.Parametric = function( if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_PARAMETRIC + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_PARAMETRIC }; } if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_PARAMETRIC; + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_PARAMETRIC; } if (GameLib.Utils.UndefinedOrNull(generatorFn)) { @@ -38,33 +38,24 @@ GameLib.D3.API.Geometry.Parametric = function( } this.stacks = stacks; - GameLib.D3.API.Geometry.call( + GameLib.D3.API.Geometry.Normal.call( this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, apiGeometry.lineDistancesNeedUpdate ); }; -GameLib.D3.API.Geometry.Parametric.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Parametric.prototype.constructor = GameLib.D3.API.Geometry.Parametric; +GameLib.D3.API.Geometry.Normal.Parametric.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Parametric.prototype.constructor = GameLib.D3.API.Geometry.Normal.Parametric; diff --git a/src/game-lib-d3-api-geometry-plane.js b/src/game-lib-d3-api-geometry-normal-plane.js similarity index 54% rename from src/game-lib-d3-api-geometry-plane.js rename to src/game-lib-d3-api-geometry-normal-plane.js index c3dc1bf..683076e 100644 --- a/src/game-lib-d3-api-geometry-plane.js +++ b/src/game-lib-d3-api-geometry-normal-plane.js @@ -1,5 +1,5 @@ /** - * GameLib.D3.API.Geometry.Plane + * GameLib.D3.API.Geometry.Normal.Plane * @param apiGeometry * @param width * @param height @@ -7,7 +7,7 @@ * @param heightSegments * @constructor */ -GameLib.D3.API.Geometry.Plane = function( +GameLib.D3.API.Geometry.Normal.Plane = function( apiGeometry, width, height, @@ -17,12 +17,12 @@ GameLib.D3.API.Geometry.Plane = function( if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_PLANE + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_PLANE }; } if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_PLANE; + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_PLANE; } if (GameLib.Utils.UndefinedOrNull(width)) { @@ -45,33 +45,24 @@ GameLib.D3.API.Geometry.Plane = function( } this.heightSegments = heightSegments; - GameLib.D3.API.Geometry.call( + GameLib.D3.API.Geometry.Normal.call( this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, apiGeometry.lineDistancesNeedUpdate ); }; -GameLib.D3.API.Geometry.Plane.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Plane.prototype.constructor = GameLib.D3.API.Geometry.Plane; +GameLib.D3.API.Geometry.Normal.Plane.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Plane.prototype.constructor = GameLib.D3.API.Geometry.Normal.Plane; diff --git a/src/game-lib-d3-api-geometry-polyhedron.js b/src/game-lib-d3-api-geometry-normal-polyhedron.js similarity index 52% rename from src/game-lib-d3-api-geometry-polyhedron.js rename to src/game-lib-d3-api-geometry-normal-polyhedron.js index 931396c..c092156 100644 --- a/src/game-lib-d3-api-geometry-polyhedron.js +++ b/src/game-lib-d3-api-geometry-normal-polyhedron.js @@ -1,5 +1,5 @@ /** - * GameLib.D3.API.Geometry.Polyhedron + * GameLib.D3.API.Geometry.Normal.Polyhedron * @param apiGeometry * @param vertices * @param indices @@ -7,7 +7,7 @@ * @param detail * @constructor */ -GameLib.D3.API.Geometry.Polyhedron = function( +GameLib.D3.API.Geometry.Normal.Polyhedron = function( apiGeometry, vertices, indices, @@ -17,12 +17,12 @@ GameLib.D3.API.Geometry.Polyhedron = function( if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_POLYHEDRON + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_POLYHEDRON }; } if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_POLYHEDRON; + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_POLYHEDRON; } if (GameLib.Utils.UndefinedOrNull(vertices)) { @@ -45,33 +45,24 @@ GameLib.D3.API.Geometry.Polyhedron = function( } this.detail = detail; - GameLib.D3.API.Geometry.call( + GameLib.D3.API.Geometry.Normal.call( this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, apiGeometry.lineDistancesNeedUpdate ); }; -GameLib.D3.API.Geometry.Polyhedron.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Polyhedron.prototype.constructor = GameLib.D3.API.Geometry.Polyhedron; +GameLib.D3.API.Geometry.Normal.Polyhedron.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Polyhedron.prototype.constructor = GameLib.D3.API.Geometry.Normal.Polyhedron; diff --git a/src/game-lib-d3-api-geometry-ring.js b/src/game-lib-d3-api-geometry-normal-ring.js similarity index 62% rename from src/game-lib-d3-api-geometry-ring.js rename to src/game-lib-d3-api-geometry-normal-ring.js index 96f43bc..0b1891c 100644 --- a/src/game-lib-d3-api-geometry-ring.js +++ b/src/game-lib-d3-api-geometry-normal-ring.js @@ -1,5 +1,5 @@ /** - * GameLib.D3.API.Geometry.Ring + * GameLib.D3.API.Geometry.Normal.Ring * @param apiGeometry * @param innerRadius * @param outerRadius @@ -9,7 +9,7 @@ * @param thetaLength * @constructor */ -GameLib.D3.API.Geometry.Ring = function( +GameLib.D3.API.Geometry.Normal.Ring = function( apiGeometry, innerRadius, outerRadius, @@ -21,12 +21,12 @@ GameLib.D3.API.Geometry.Ring = function( if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_RING + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_RING }; } if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_RING; + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_RING; } if (GameLib.Utils.UndefinedOrNull(innerRadius)) { @@ -59,33 +59,24 @@ GameLib.D3.API.Geometry.Ring = function( } this.thetaLength = thetaLength; - GameLib.D3.API.Geometry.call( + GameLib.D3.API.Geometry.Normal.call( this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, apiGeometry.lineDistancesNeedUpdate ); }; -GameLib.D3.API.Geometry.Ring.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Ring.prototype.constructor = GameLib.D3.API.Geometry.Ring; +GameLib.D3.API.Geometry.Normal.Ring.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Ring.prototype.constructor = GameLib.D3.API.Geometry.Normal.Ring; diff --git a/src/game-lib-d3-api-geometry-normal-shape.js b/src/game-lib-d3-api-geometry-normal-shape.js new file mode 100644 index 0000000..3c05c75 --- /dev/null +++ b/src/game-lib-d3-api-geometry-normal-shape.js @@ -0,0 +1,54 @@ +/** + * GameLib.D3.API.Geometry.Normal.Shape + * @param apiGeometry + * @param shapes + * @param curveSegments + * @constructor + */ +GameLib.D3.API.Geometry.Normal.Shape = function( + apiGeometry, + shapes, + curveSegments +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SHAPE + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SHAPE; + } + + if (GameLib.Utils.UndefinedOrNull(shapes)) { + shapes = []; + } + this.shapes = shapes; + + if (GameLib.Utils.UndefinedOrNull(curveSegments)) { + curveSegments = 12; + } + this.curveSegments = curveSegments; + + GameLib.D3.API.Geometry.Normal.call( + this, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, + apiGeometry.lineDistancesNeedUpdate + ); +}; + +GameLib.D3.API.Geometry.Normal.Shape.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Shape.prototype.constructor = GameLib.D3.API.Geometry.Normal.Shape; diff --git a/src/game-lib-d3-api-geometry-sphere.js b/src/game-lib-d3-api-geometry-normal-sphere.js similarity index 62% rename from src/game-lib-d3-api-geometry-sphere.js rename to src/game-lib-d3-api-geometry-normal-sphere.js index d9950c5..8420f87 100644 --- a/src/game-lib-d3-api-geometry-sphere.js +++ b/src/game-lib-d3-api-geometry-normal-sphere.js @@ -1,5 +1,5 @@ /** - * GameLib.D3.API.Geometry.Sphere + * GameLib.D3.API.Geometry.Normal.Sphere * @param apiGeometry * @param radius * @param widthSegments @@ -10,7 +10,7 @@ * @param thetaLength * @constructor */ -GameLib.D3.API.Geometry.Sphere = function( +GameLib.D3.API.Geometry.Normal.Sphere = function( apiGeometry, radius, widthSegments, @@ -23,12 +23,12 @@ GameLib.D3.API.Geometry.Sphere = function( if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_SPHERE + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SPHERE }; } if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_SPHERE; + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SPHERE; } if (GameLib.Utils.UndefinedOrNull(radius)) { @@ -62,37 +62,28 @@ GameLib.D3.API.Geometry.Sphere = function( this.thetaStart = thetaStart; if (GameLib.Utils.UndefinedOrNull(thetaLength)) { - thetaLength = Math.PI * 2; + thetaLength = Math.PI; } this.thetaLength = thetaLength; - GameLib.D3.API.Geometry.call( + GameLib.D3.API.Geometry.Normal.call( this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, apiGeometry.lineDistancesNeedUpdate ); }; -GameLib.D3.API.Geometry.Sphere.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Sphere.prototype.constructor = GameLib.D3.API.Geometry.Sphere; +GameLib.D3.API.Geometry.Normal.Sphere.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Sphere.prototype.constructor = GameLib.D3.API.Geometry.Normal.Sphere; diff --git a/src/game-lib-d3-api-geometry-normal-tetrahedron.js b/src/game-lib-d3-api-geometry-normal-tetrahedron.js new file mode 100644 index 0000000..c70239d --- /dev/null +++ b/src/game-lib-d3-api-geometry-normal-tetrahedron.js @@ -0,0 +1,54 @@ +/** + * GameLib.D3.API.Geometry.Normal.Tetrahedron + * @param apiGeometry + * @param radius + * @param detail + * @constructor + */ +GameLib.D3.API.Geometry.Normal.Tetrahedron = function( + apiGeometry, + radius, + detail +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TETRAHEDRON + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TETRAHEDRON; + } + + if (GameLib.Utils.UndefinedOrNull(radius)) { + radius = 1; + } + this.radius = radius; + + if (GameLib.Utils.UndefinedOrNull(detail)) { + detail = 0; + } + this.detail = detail; + + GameLib.D3.API.Geometry.Normal.call( + this, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, + apiGeometry.lineDistancesNeedUpdate + ); +}; + +GameLib.D3.API.Geometry.Normal.Tetrahedron.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Tetrahedron.prototype.constructor = GameLib.D3.API.Geometry.Normal.Tetrahedron; diff --git a/src/game-lib-d3-api-geometry-text.js b/src/game-lib-d3-api-geometry-normal-text.js similarity index 64% rename from src/game-lib-d3-api-geometry-text.js rename to src/game-lib-d3-api-geometry-normal-text.js index c0b5625..3b6e712 100644 --- a/src/game-lib-d3-api-geometry-text.js +++ b/src/game-lib-d3-api-geometry-normal-text.js @@ -1,5 +1,5 @@ /** - * GameLib.D3.API.Geometry.Text + * GameLib.D3.API.Geometry.Normal.Text * @param apiGeometry * @param text * @param font @@ -12,7 +12,7 @@ * @param bevelSegments * @constructor */ -GameLib.D3.API.Geometry.Text = function( +GameLib.D3.API.Geometry.Normal.Text = function( apiGeometry, text, font, @@ -27,12 +27,12 @@ GameLib.D3.API.Geometry.Text = function( if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_TEXT + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TEXT }; } if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_TEXT; + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TEXT; } if (GameLib.Utils.UndefinedOrNull(text)) { @@ -46,12 +46,12 @@ GameLib.D3.API.Geometry.Text = function( this.font = font; if (GameLib.Utils.UndefinedOrNull(size)) { - size = 100; + size = 10; } this.size = size; if (GameLib.Utils.UndefinedOrNull(height)) { - height = 50; + height = 5; } this.height = height; @@ -66,7 +66,7 @@ GameLib.D3.API.Geometry.Text = function( this.bevelEnabled = bevelEnabled; if (GameLib.Utils.UndefinedOrNull(bevelThickness)) { - bevelThickness = 10; + bevelThickness = 1; } this.bevelThickness = bevelThickness; @@ -80,33 +80,24 @@ GameLib.D3.API.Geometry.Text = function( } this.bevelSegments = bevelSegments; - GameLib.D3.API.Geometry.call( + GameLib.D3.API.Geometry.Normal.call( this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, apiGeometry.lineDistancesNeedUpdate ); }; -GameLib.D3.API.Geometry.Text.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Text.prototype.constructor = GameLib.D3.API.Geometry.Text; +GameLib.D3.API.Geometry.Normal.Text.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Text.prototype.constructor = GameLib.D3.API.Geometry.Normal.Text; diff --git a/src/game-lib-d3-api-geometry-torus-knot.js b/src/game-lib-d3-api-geometry-normal-torus-knot.js similarity index 58% rename from src/game-lib-d3-api-geometry-torus-knot.js rename to src/game-lib-d3-api-geometry-normal-torus-knot.js index 200d3dc..36ed171 100644 --- a/src/game-lib-d3-api-geometry-torus-knot.js +++ b/src/game-lib-d3-api-geometry-normal-torus-knot.js @@ -1,5 +1,5 @@ /** - * GameLib.D3.API.Geometry.TorusKnot + * GameLib.D3.API.Geometry.Normal.TorusKnot * @param apiGeometry * @param radius * @param tube @@ -9,7 +9,7 @@ * @param q * @constructor */ -GameLib.D3.API.Geometry.TorusKnot = function( +GameLib.D3.API.Geometry.Normal.TorusKnot = function( apiGeometry, radius, tube, @@ -21,12 +21,12 @@ GameLib.D3.API.Geometry.TorusKnot = function( if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS_KNOT + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TORUS_KNOT }; } if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS_KNOT; + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TORUS_KNOT; } if (GameLib.Utils.UndefinedOrNull(radius)) { @@ -59,33 +59,24 @@ GameLib.D3.API.Geometry.TorusKnot = function( } this.q = q; - GameLib.D3.API.Geometry.call( + GameLib.D3.API.Geometry.Normal.call( this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, apiGeometry.lineDistancesNeedUpdate ); }; -GameLib.D3.API.Geometry.TorusKnot.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.TorusKnot.prototype.constructor = GameLib.D3.API.Geometry.TorusKnot; +GameLib.D3.API.Geometry.Normal.TorusKnot.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.TorusKnot.prototype.constructor = GameLib.D3.API.Geometry.Normal.TorusKnot; diff --git a/src/game-lib-d3-api-geometry-torus.js b/src/game-lib-d3-api-geometry-normal-torus.js similarity index 57% rename from src/game-lib-d3-api-geometry-torus.js rename to src/game-lib-d3-api-geometry-normal-torus.js index b9ac0f3..d9fd066 100644 --- a/src/game-lib-d3-api-geometry-torus.js +++ b/src/game-lib-d3-api-geometry-normal-torus.js @@ -1,5 +1,5 @@ /** - * GameLib.D3.API.Geometry.Torus + * GameLib.D3.API.Geometry.Normal.Torus * @param apiGeometry * @param radius * @param tube @@ -8,7 +8,7 @@ * @param arc * @constructor */ -GameLib.D3.API.Geometry.Torus = function( +GameLib.D3.API.Geometry.Normal.Torus = function( apiGeometry, radius, tube, @@ -19,12 +19,12 @@ GameLib.D3.API.Geometry.Torus = function( if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TORUS }; } if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_TORUS; + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TORUS; } if (GameLib.Utils.UndefinedOrNull(radius)) { @@ -52,33 +52,24 @@ GameLib.D3.API.Geometry.Torus = function( } this.arc = arc; - GameLib.D3.API.Geometry.call( + GameLib.D3.API.Geometry.Normal.call( this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, apiGeometry.lineDistancesNeedUpdate ); }; -GameLib.D3.API.Geometry.Torus.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Torus.prototype.constructor = GameLib.D3.API.Geometry.Torus; +GameLib.D3.API.Geometry.Normal.Torus.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Torus.prototype.constructor = GameLib.D3.API.Geometry.Normal.Torus; diff --git a/src/game-lib-d3-api-geometry-tube.js b/src/game-lib-d3-api-geometry-normal-tube.js similarity index 58% rename from src/game-lib-d3-api-geometry-tube.js rename to src/game-lib-d3-api-geometry-normal-tube.js index 8b11fcc..e34d016 100644 --- a/src/game-lib-d3-api-geometry-tube.js +++ b/src/game-lib-d3-api-geometry-normal-tube.js @@ -1,5 +1,5 @@ /** - * GameLib.D3.API.Geometry.Tube + * GameLib.D3.API.Geometry.Normal.Tube * @param apiGeometry * @param path * @param tubularSegments @@ -8,7 +8,7 @@ * @param closed * @constructor */ -GameLib.D3.API.Geometry.Tube = function( +GameLib.D3.API.Geometry.Normal.Tube = function( apiGeometry, path, tubularSegments, @@ -19,12 +19,12 @@ GameLib.D3.API.Geometry.Tube = function( if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_TUBE + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TUBE }; } if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_TUBE; + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TUBE; } if (GameLib.Utils.UndefinedOrNull(path)) { @@ -52,33 +52,24 @@ GameLib.D3.API.Geometry.Tube = function( } this.closed = closed; - GameLib.D3.API.Geometry.call( + GameLib.D3.API.Geometry.Normal.call( this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, apiGeometry.lineDistancesNeedUpdate ); }; -GameLib.D3.API.Geometry.Tube.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Tube.prototype.constructor = GameLib.D3.API.Geometry.Tube; +GameLib.D3.API.Geometry.Normal.Tube.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Tube.prototype.constructor = GameLib.D3.API.Geometry.Normal.Tube; diff --git a/src/game-lib-d3-api-geometry-normal-wireframe.js b/src/game-lib-d3-api-geometry-normal-wireframe.js new file mode 100644 index 0000000..bd42902 --- /dev/null +++ b/src/game-lib-d3-api-geometry-normal-wireframe.js @@ -0,0 +1,47 @@ +/** + * GameLib.D3.API.Geometry.Normal.Wireframe + * @param apiGeometry + * @param geometry + * @constructor + */ +GameLib.D3.API.Geometry.Normal.Wireframe = function( + apiGeometry, + geometry +) { + + if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { + apiGeometry = { + geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_WIREFRAME + }; + } + + if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { + apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_WIREFRAME; + } + + if (GameLib.Utils.UndefinedOrNull(geometry)) { + geometry = null; + } + this.geometry = geometry; + + GameLib.D3.API.Geometry.Normal.call( + this, + apiGeometry, + apiGeometry.colors, + apiGeometry.lineDistances, + apiGeometry.morphTargets, + apiGeometry.morphNormals, + apiGeometry.skinWeights, + apiGeometry.skinIndices, + apiGeometry.verticesNeedsUpdate, + apiGeometry.elementsNeedUpdate, + apiGeometry.uvsNeedUpdate, + apiGeometry.normalsNeedUpdate, + apiGeometry.colorsNeedUpdate, + apiGeometry.groupsNeedUpdate, + apiGeometry.lineDistancesNeedUpdate + ); +}; + +GameLib.D3.API.Geometry.Normal.Wireframe.prototype = Object.create(GameLib.D3.API.Geometry.Normal.prototype); +GameLib.D3.API.Geometry.Normal.Wireframe.prototype.constructor = GameLib.D3.API.Geometry.Normal.Wireframe; diff --git a/src/game-lib-d3-api-geometry-octahedron.js b/src/game-lib-d3-api-geometry-octahedron.js deleted file mode 100644 index 856b6c8..0000000 --- a/src/game-lib-d3-api-geometry-octahedron.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * GameLib.D3.API.Geometry.Octahedron - * @param apiGeometry - * @param radius - * @param detail - * @constructor - */ -GameLib.D3.API.Geometry.Octahedron = function( - apiGeometry, - radius, - detail -) { - - if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { - apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_OCTAHEDRON - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_OCTAHEDRON; - } - - if (GameLib.Utils.UndefinedOrNull(radius)) { - radius = 1; - } - this.radius = radius; - - if (GameLib.Utils.UndefinedOrNull(detail)) { - detail = 0; - } - this.detail = detail; - - GameLib.D3.API.Geometry.call( - this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, - apiGeometry.lineDistancesNeedUpdate - ); -}; - -GameLib.D3.API.Geometry.Octahedron.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Octahedron.prototype.constructor = GameLib.D3.API.Geometry.Octahedron; diff --git a/src/game-lib-d3-api-geometry-shape.js b/src/game-lib-d3-api-geometry-shape.js deleted file mode 100644 index 654f7c6..0000000 --- a/src/game-lib-d3-api-geometry-shape.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * GameLib.D3.API.Geometry.Shape - * @param apiGeometry - * @param shapes - * @param curveSegments - * @constructor - */ -GameLib.D3.API.Geometry.Shape = function( - apiGeometry, - shapes, - curveSegments -) { - - if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { - apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_SHAPE - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_SHAPE; - } - - if (GameLib.Utils.UndefinedOrNull(shapes)) { - shapes = []; - } - this.shapes = shapes; - - if (GameLib.Utils.UndefinedOrNull(curveSegments)) { - curveSegments = 12; - } - this.curveSegments = curveSegments; - - GameLib.D3.API.Geometry.call( - this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, - apiGeometry.lineDistancesNeedUpdate - ); -}; - -GameLib.D3.API.Geometry.Shape.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Shape.prototype.constructor = GameLib.D3.API.Geometry.Shape; diff --git a/src/game-lib-d3-api-geometry-tetrahedron.js b/src/game-lib-d3-api-geometry-tetrahedron.js deleted file mode 100644 index c8fbd93..0000000 --- a/src/game-lib-d3-api-geometry-tetrahedron.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * GameLib.D3.API.Geometry.Tetrahedron - * @param apiGeometry - * @param radius - * @param detail - * @constructor - */ -GameLib.D3.API.Geometry.Tetrahedron = function( - apiGeometry, - radius, - detail -) { - - if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { - apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_TETRAHEDRON - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_TETRAHEDRON; - } - - if (GameLib.Utils.UndefinedOrNull(radius)) { - radius = 1; - } - this.radius = radius; - - if (GameLib.Utils.UndefinedOrNull(detail)) { - detail = 0; - } - this.detail = detail; - - GameLib.D3.API.Geometry.call( - this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, - apiGeometry.lineDistancesNeedUpdate - ); -}; - -GameLib.D3.API.Geometry.Tetrahedron.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Tetrahedron.prototype.constructor = GameLib.D3.API.Geometry.Tetrahedron; diff --git a/src/game-lib-d3-api-geometry-wireframe.js b/src/game-lib-d3-api-geometry-wireframe.js deleted file mode 100644 index 322bf7d..0000000 --- a/src/game-lib-d3-api-geometry-wireframe.js +++ /dev/null @@ -1,54 +0,0 @@ -/** - * GameLib.D3.API.Geometry.Wireframe - * @param apiGeometry - * @param geometry - * @constructor - */ -GameLib.D3.API.Geometry.Wireframe = function( - apiGeometry, - geometry -) { - - if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { - apiGeometry = { - geometryType: GameLib.D3.API.Geometry.GEOMETRY_TYPE_WIREFRAME - }; - } - - if (GameLib.Utils.UndefinedOrNull(apiGeometry.geometryType)) { - apiGeometry.geometryType = GameLib.D3.API.Geometry.GEOMETRY_TYPE_WIREFRAME; - } - - if (GameLib.Utils.UndefinedOrNull(geometry)) { - geometry = null; - } - this.geometry = geometry; - - GameLib.D3.API.Geometry.call( - this, - apiGeometry.id, - apiGeometry.name, - apiGeometry.geometryType, - apiGeometry.parentEntity, - apiGeometry.boundingBox, - apiGeometry.boundingSphere, - apiGeometry.colors, - apiGeometry.faces, - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, - apiGeometry.lineDistancesNeedUpdate - ); -}; - -GameLib.D3.API.Geometry.Wireframe.prototype = Object.create(GameLib.D3.API.Geometry.prototype); -GameLib.D3.API.Geometry.Wireframe.prototype.constructor = GameLib.D3.API.Geometry.Wireframe; diff --git a/src/game-lib-d3-buffer-geometry-box.js b/src/game-lib-d3-buffer-geometry-box.js deleted file mode 100644 index 1ab00a7..0000000 --- a/src/game-lib-d3-buffer-geometry-box.js +++ /dev/null @@ -1,103 +0,0 @@ -/** - * GameLib.D3.BufferGeometry.Box - * @param graphics GameLib.GraphicsRuntime - * @param apiBoxBufferGeometry - * @constructor - */ -GameLib.D3.BufferGeometry.Box = function( - graphics, - apiBoxBufferGeometry -) { - - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (GameLib.Utils.UndefinedOrNull(apiBoxBufferGeometry)) { - apiBoxBufferGeometry = { - bufferGeometryType : GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_BOX - }; - } - - GameLib.D3.API.BufferGeometry.Box.call( - this, - apiBoxBufferGeometry, - apiBoxBufferGeometry.width, - apiBoxBufferGeometry.height, - apiBoxBufferGeometry.depth, - apiBoxBufferGeometry.widthSegments, - apiBoxBufferGeometry.heightSegments, - apiBoxBufferGeometry.depthSegments - ); - - GameLib.D3.BufferGeometry.call( - this, - this.graphics, - apiBoxBufferGeometry - ); - -}; - -GameLib.D3.BufferGeometry.Box.prototype = Object.create(GameLib.D3.BufferGeometry.prototype); -GameLib.D3.BufferGeometry.Box.prototype.constructor = GameLib.D3.BufferGeometry.Box; - -/** - * Creates a light instance - * @returns {*} - */ -GameLib.D3.BufferGeometry.Box.prototype.createInstance = function() { - - this.instance = new THREE.BoxBufferGeometry( - this.width, - this.height, - this.depth, - this.widthSegments, - this.heightSegments, - this.depthSegments - ); - - GameLib.D3.BufferGeometry.prototype.createInstance.call(this); -}; - -/** - * Updates the instance with the current state - */ -GameLib.D3.BufferGeometry.Box.prototype.updateInstance = function(property, oldTarget) { - - if ( - property === 'width' || - property === 'height' || - property === 'depth' || - property === 'widthSegments' || - property === 'heightSegments' || - property === 'depthSegments' - ) { - console.warn('todo: check if i can update this without creating a new instance'); - //this.createInstance(); - this.instance.width = this.width; - this.instance.attributes.position.needsUpdate = true; - return; - } - - GameLib.D3.BufferGeometry.prototype.updateInstance.call(this, property); -}; - -/** - * Converts a GameLib.D3.BufferGeometry to a GameLib.D3.API.BufferGeometry - * @returns {GameLib.D3.API.BufferGeometry} - */ -GameLib.D3.BufferGeometry.Box.prototype.toApiObject = function() { - - var apiBufferGeometry = GameLib.D3.BufferGeometry.prototype.toApiObject.call(this); - - var apiBoxBufferGeometry = new GameLib.D3.API.BufferGeometry.Box( - apiBufferGeometry, - this.width, - this.height, - this.depth, - this.widthSegments, - this.heightSegments, - this.depthSegments - ); - - return apiBoxBufferGeometry; -}; diff --git a/src/game-lib-d3-font.js b/src/game-lib-d3-font.js index d8fc2bb..874457e 100644 --- a/src/game-lib-d3-font.js +++ b/src/game-lib-d3-font.js @@ -42,6 +42,9 @@ GameLib.D3.Font.prototype.createInstance = function() { }, function(fontInstance) { this.instance = fontInstance; + + console.log('font instance loaded'); + GameLib.Component.prototype.createInstance.call(this); }.bind(this), function(error) { @@ -56,14 +59,11 @@ GameLib.D3.Font.prototype.createInstance = function() { /** * Updates the instance with the current state */ -GameLib.D3.Font.prototype.updateInstance = function() { +GameLib.D3.Font.prototype.updateInstance = function(property) { - GameLib.Event.Emit( - GameLib.Event.LOAD_FONT, - { - font : this - } - ); + if (property === 'url') { + this.createInstance(); + } GameLib.Component.prototype.updateInstance.call(this, property); }; diff --git a/src/game-lib-d3-geometry-a.js b/src/game-lib-d3-geometry-a.js index 95c9a77..7fcab67 100644 --- a/src/game-lib-d3-geometry-a.js +++ b/src/game-lib-d3-geometry-a.js @@ -15,7 +15,7 @@ GameLib.D3.Geometry = function( if (GameLib.Utils.UndefinedOrNull(apiGeometry)) { apiGeometry = { - geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NONE }; } @@ -25,34 +25,23 @@ GameLib.D3.Geometry = function( apiGeometry.name, apiGeometry.geometryType, apiGeometry.parentEntity, + apiGeometry.parentMesh, apiGeometry.boundingBox, apiGeometry.boundingSphere, - apiGeometry.colors, apiGeometry.faces, - apiGeometry.lineDistances, - apiGeometry.morphTargets, - apiGeometry.morphNormals, - apiGeometry.skinWeights, - apiGeometry.skinIndices, - apiGeometry.vertices, - apiGeometry.verticesNeedsUpdate, - apiGeometry.elementsNeedUpdate, - apiGeometry.uvsNeedUpdate, - apiGeometry.normalsNeedUpdate, - apiGeometry.colorsNeedUpdate, - apiGeometry.groupsNeedUpdate, - apiGeometry.lineDistancesNeedUpdate + apiGeometry.vertices ); - this.colors = this.colors.map( - function(color) { - return new GameLib.Color( - this.graphics, - color - ) - }.bind(this) + this.boundingBox = new GameLib.Box3( + this.graphics, + this.boundingBox ); - + + this.boundingSphere = new GameLib.Sphere( + this.graphics, + this.boundingSphere + ); + this.faces = this.faces.map( function(face) { return new GameLib.D3.Face( @@ -61,27 +50,7 @@ GameLib.D3.Geometry = function( ) }.bind(this) ); - - this.skinWeights = this.skinWeights.map( - function(skinWeight) { - return new GameLib.Vector4( - this.graphics, - skinWeight, - this - ) - }.bind(this) - ); - this.skinIndices = this.skinIndices.map( - function(skinIndex) { - return new GameLib.Vector4( - this.graphics, - skinIndex, - this - ) - }.bind(this) - ); - this.vertices = this.vertices.map( function(vertex) { return new GameLib.D3.Vertex( @@ -90,25 +59,36 @@ GameLib.D3.Geometry = function( ) }.bind(this) ); - + var linkedObjects = {}; - + switch (this.geometryType) { - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_EDGES : - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_WIREFRAME : + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EDGES : + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_WIREFRAME : linkedObjects.geometry = GameLib.D3.Geometry; break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_EXTRUDE : - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_SHAPE : + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EXTRUDE : + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SHAPE : linkedObjects.shapes = [GameLib.Curve.Path.D2.Shape]; break; - case GameLib.D3.API.Geometry.GEOMETRY_TYPE_TEXT : + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TEXT : + linkedObjects.font = GameLib.D3.Font; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_EXTRUDE: + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SHAPE : + linkedObjects.shapes = [GameLib.Curve.Path.D2.Shape]; + break; + case GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TEXT : linkedObjects.font = GameLib.D3.Font; break; default : break; } - + + if (this instanceof GameLib.D3.Geometry.Buffer) { + linkedObjects.groups = [GameLib.Group]; + } + GameLib.Component.call( this, linkedObjects @@ -118,61 +98,11 @@ GameLib.D3.Geometry = function( GameLib.D3.Geometry.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.Geometry.prototype.constructor = GameLib.D3.Geometry; -GameLib.D3.Geometry.prototype.applyToInstance = function(property) { - - if (property === 'faces') { - - this.faces = GameLib.Utils.SortFacesByMaterialIndex(this.faces); - - var standardUvs = []; - - /** - * Now setup each face and collect UV information during this process - */ - this.instance.faces = this.faces.map( - function (face) { - - if (face.uvs[0].length > 0) { - standardUvs.push( - face.uvs[0].map( - function (uv) { - return uv.instance; - } - ) - ); - } - - if (!face.instance) { - face.createInstance(this); - } - - return face.instance; - }.bind(this) - ); - - /** - * UV data - but only if it exists - */ - if (standardUvs.length > 0) { - this.instance.faceVertexUvs = [standardUvs]; - } - - return; - } - - if (property === 'vertices') { - this.instance.vertices = this.vertices.map( - function (vertex) { - return vertex.position.instance; - } - ); - } -}; - GameLib.D3.Geometry.prototype.createInstance = function() { if (GameLib.Utils.UndefinedOrNull(this.instance)) { - this.instance = new THREE.Geometry(); + console.warn('do not instantiate this class directly'); + return; } this.instance.name = this.name; @@ -200,88 +130,30 @@ GameLib.D3.Geometry.prototype.createInstance = function() { this.boundingSphere.center.z = this.instance.boundingSphere.center.z; this.boundingSphere.radius = this.instance.boundingSphere.radius; - /** - * Setup colors - */ - this.instance.colors = this.colors.map( - function(color) { - return color.instance; - } - ); - - /** - * Setup faces - */ - this.applyToInstance('faces'); - - /** - * Setup line distances - we let three calculate it and then update our information - */ - this.instance.computeLineDistances(); - this.lineDistances = this.instance.lineDistances; - - /** - * Some more stuff - */ - if (this.morphTargets && this.morphTargets.length > 0) { - this.instance.morphTargets = this.morphTargets; - } - - if (this.morphNormals && this.morphNormals.length > 0) { - this.instance.morphNormals = this.morphNormals; - } - - if (this.skinWeights && this.skinWeights.length > 0) { - this.instance.skinWeights = this.skinWeights.map( - function(skinWeight) { - return skinWeight.instance; - } - ); - } - - if (this.skinIndices && this.skinIndices.length > 0) { - this.instance.skinIndices = this.skinIndices.map( - function(skinIndex) { - return skinIndex.instance; - } - ); - } - - /** - * Setup vertices - */ - this.applyToInstance('vertices'); - - this.instance.computeFaceNormals(); - this.instance.computeVertexNormals(); - - // this.instance.verticesNeedUpdate = true; - // this.instance.elementsNeedUpdate = true; - // this.instance.uvsNeedUpdate = true; - // this.instance.normalsNeedUpdate = true; - // this.instance.colorsNeedUpdate = true; - // this.instance.groupsNeedUpdate = true; - // this.instance.lineDistancesNeedUpdate = true; - - // /** - // * Re-compute normals - we don't do this for buffer geometry because it assigns to every vertex normal the face - // * normal - essentially disabling 'smooth shading' - // */ - // geometry.computeFaceNormals(); - // // geometry.computeBoundingBox(); - // geometry.computeVertexNormals(); - GameLib.Component.prototype.createInstance.call(this); }; +/** + * Update Instance + * @param property + */ GameLib.D3.Geometry.prototype.updateInstance = function(property) { if (GameLib.Utils.UndefinedOrNull(this.instance)) { console.warn('no geometry instance'); return; } - + + if (property === 'parentMesh') { + if (this.parentMesh) { + console.log('geometry assigned to new parent mesh ' + this.parentMesh.name); + } else { + console.log('geometry removed from parent'); + } + return; + } + if (property === 'name') { this.instance.name = this.name; return; @@ -297,115 +169,14 @@ GameLib.D3.Geometry.prototype.updateInstance = function(property) { return; } - if (property === 'colors') { - this.instance.colors = this.colors.map( - function(color) { - return color.instance; - } - ); - this.instance.colorsNeedUpdate = true; - return; - } - - if (property === 'faces') { - this.applyToInstance(property); - this.instance.elementsNeedUpdate = true; - this.instance.groupsNeedUpdate = true; - return; + if ( + property === 'faces' || + property === 'vertices' + ) { + console.warn('the child class should take care of updating faces or vertices'); + return; } - if (property === 'lineDistances') { - this.instance.lineDistances = this.lineDistances; - this.instance.lineDistancesNeedUpdate = true; - return; - } - - if (property === 'morphTargets') { - this.instance.morphTargets = this.morphTargets; - return; - } - - if (property === 'morphNormals') { - this.instance.morphNormals = this.morphNormals; - return; - } - - if (property === 'skinWeights') { - - if (this.skinWeights) { - this.instance.skinWeights = this.skinWeights.map( - function(skinWeight) { - return skinWeight.instance; - } - ) - } else { - console.warn('todo : check deleting skinweights'); - delete this.instance.skinWeights; - } - - return; - } - - if (property === 'skinIndices') { - - if (this.skinIndices) { - this.instance.skinIndices = this.skinIndices.map( - function(skinIndex) { - return skinIndex.instance; - } - ) - } else { - console.warn('todo : check deleting skinIndices'); - delete this.instance.skinIndices; - } - - return; - } - - if (property === 'vertices') { - this.applyToInstance(property); - this.instance.verticesNeedUpdate = true; - return; - } - - /** - * Manually trigger updates (and ignore our setting) - */ - if (property === 'verticesNeedsUpdate') { - this.instance.verticesNeedsUpdate = true; - this.verticesNeedUpdate = false; - } - - if (property === 'elementsNeedUpdate') { - this.instance.elementsNeedUpdate = true; - this.elementsNeedUpdate = false; - } - - if (property === 'uvsNeedUpdate') { - this.instance.uvsNeedUpdate = true; - this.uvsNeedUpdate = false; - } - - if (property === 'normalsNeedUpdate') { - this.instance.normalsNeedUpdate = true; - this.normalsNeedUpdate = false; - } - - if (property === 'colorsNeedUpdate') { - this.instance.colorsNeedUpdate = true; - this.colorsNeedUpdate = false; - } - - if (property === 'groupsNeedUpdate') { - this.instance.groupsNeedUpdate = true; - this.groupsNeedUpdate = false; - } - - if (property === 'lineDistancesNeedUpdate') { - this.instance.lineDistancesNeedUpdate = true; - this.lineDistancesNeedUpdate = false; - } - GameLib.Component.prototype.updateInstance.call(this, property); }; @@ -416,36 +187,19 @@ GameLib.D3.Geometry.prototype.updateInstance = function(property) { GameLib.D3.Geometry.prototype.toApiObject = function() { var apiGeometry = new GameLib.D3.API.Geometry( + this.id, this.name, this.geometryType, - this.isBufferGeometry, GameLib.Utils.IdOrNull(this.parentEntity), + GameLib.Utils.IdOrNull(this.parentMesh), this.boundingBox.toApiObject(), this.boundingSphere.toApiObject(), - this.colors.map( - function(color) { - return color.toApiObject(); - } - ), this.faces.map( function(face) { return face.toApiObject(); } ), - this.lineDistances, - this.morphTargets, - this.morphNormals, - this.skinWeights.map( - function(skinWeight) { - return skinWeight.toApiObject(); - } - ), - this.skinIndices.map( - function(skinIndex) { - return skinIndex.toApiObject(); - } - ), this.vertices.map( function (vertex) { return vertex.toApiObject(); @@ -461,108 +215,6 @@ GameLib.D3.Geometry.prototype.toApiObject = function() { * Update GameLib.D3.Geometry from instance */ GameLib.D3.Geometry.prototype.updateFromInstance = function() { - - var processed = 0; - - this.instance.faces.map(function(face, faceIndex){ - - processed++; - - if (processed % 100 === 0) { - console.log('processed ' + processed + ' faces'); - } - - this.faces.push( - new GameLib.D3.Face( - this.graphics, - new GameLib.D3.API.Face( - null, - null, - face.a, - face.b, - face.c, - face.materialIndex, - [[ - new GameLib.API.Vector2( - this.instance.faceVertexUvs[0][faceIndex][0].x, - this.instance.faceVertexUvs[0][faceIndex][0].y - ), - new GameLib.API.Vector2( - this.instance.faceVertexUvs[0][faceIndex][1].x, - this.instance.faceVertexUvs[0][faceIndex][1].y - ), - new GameLib.API.Vector2( - this.instance.faceVertexUvs[0][faceIndex][2].x, - this.instance.faceVertexUvs[0][faceIndex][2].y - ) - ]], - new GameLib.Color( - this.graphics, - new GameLib.API.Color( - face.color.r, - face.color.g, - face.color.b - ) - ), - face.vertexColors.map(function(vertexColor){ - return new GameLib.Color( - this.graphics, - new GameLib.API.Color( - vertexColor.r, - vertexColor.g, - vertexColor.b - ) - ) - }.bind(this)), - face.vertexNormals.map(function(vertexNormal){ - return new GameLib.Vector3( - this.graphics, - new GameLib.API.Vector3( - vertexNormal.x, - vertexNormal.y, - vertexNormal.z - ) - ) - }.bind(this)), - new GameLib.Vector3( - this.graphics, - new GameLib.API.Vector3( - face.normal.x, - face.normal.y, - face.normal.z - ) - ) - ) - ) - ) - }.bind(this)); - - processed = 0; - - this.instance.vertices.map(function(vertex){ - - processed++; - - if (processed % 100 === 0) { - console.log('processed ' + processed + ' vertices'); - } - - this.vertices.push( - new GameLib.D3.Vertex( - this.graphics, - new GameLib.D3.API.Vertex( - new GameLib.Vector3( - this.graphics, - new GameLib.API.Vector3( - vertex.x, - vertex.y, - vertex.z - ) - ) - ) - ) - ) - - }.bind(this)); - -}; \ No newline at end of file + console.warn('the child class should take care of updating from instance'); + return; +}; diff --git a/src/game-lib-d3-buffer-geometry-a.js b/src/game-lib-d3-geometry-buffer-a.js similarity index 64% rename from src/game-lib-d3-buffer-geometry-a.js rename to src/game-lib-d3-geometry-buffer-a.js index d11002c..076a73c 100644 --- a/src/game-lib-d3-buffer-geometry-a.js +++ b/src/game-lib-d3-geometry-buffer-a.js @@ -1,11 +1,11 @@ /** - * GameLib.D3.BufferGeometry + * GameLib.D3.Geometry.Buffer * @param graphics * @param apiBufferGeometry - * @property bufferGeometryType + * @property geometryType * @constructor */ -GameLib.D3.BufferGeometry = function( +GameLib.D3.Geometry.Buffer = function( graphics, apiBufferGeometry ) { @@ -15,86 +15,88 @@ GameLib.D3.BufferGeometry = function( if (GameLib.Utils.UndefinedOrNull(apiBufferGeometry)) { apiBufferGeometry = { - bufferGeometryType : GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_NONE + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER }; } - GameLib.D3.API.BufferGeometry.call( + GameLib.D3.API.Geometry.Buffer.call( this, - apiBufferGeometry.id, - apiBufferGeometry.name, - apiBufferGeometry.bufferGeometryType, - apiBufferGeometry.parentEntity, - apiBufferGeometry.faces, - apiBufferGeometry.vertices, + apiBufferGeometry, apiBufferGeometry.attributes, - apiBufferGeometry.boundingBox, - apiBufferGeometry.boundingSphere, apiBufferGeometry.drawRange, apiBufferGeometry.groups, apiBufferGeometry.index, apiBufferGeometry.morphAttributes ); - this.faces = this.faces.map( - function(face) { - return new GameLib.D3.Face( - this.graphics, - face - ) - }.bind(this) + + this.drawRange = new GameLib.DrawRange( + this.graphics, + this.drawRange, + this ); - - this.vertices = this.vertices.map( - function(vertex) { - return new GameLib.D3.Vertex( - this.graphics, - vertex - ) + + this.groups = this.groups.map( + function(group) { + if (group instanceof GameLib.API.Group) { + return new GameLib.Group( + this.graphics, + group, + this + ) + } else { + return group; + } }.bind(this) ); - var linkedObjects = {}; - - switch (this.bufferGeometryType) { - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_EXTRUDE : - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_SHAPE : - linkedObjects.shapes = [GameLib.Curve.Path.D2.Shape]; - break; - case GameLib.D3.API.BufferGeometry.BUFFER_GEOMETRY_TYPE_TEXT : - linkedObjects.font = GameLib.D3.Font; - break; - default : - break; - } - - GameLib.Component.call( + GameLib.D3.Geometry.call( this, - linkedObjects + this.graphics, + this ); }; -GameLib.D3.BufferGeometry.prototype = Object.create(GameLib.Component.prototype); -GameLib.D3.BufferGeometry.prototype.constructor = GameLib.D3.BufferGeometry; +GameLib.D3.Geometry.Buffer.prototype = Object.create(GameLib.D3.Geometry.prototype); +GameLib.D3.Geometry.Buffer.prototype.constructor = GameLib.D3.Geometry.Buffer; -GameLib.D3.BufferGeometry.prototype.createInstance = function() { +GameLib.D3.Geometry.Buffer.prototype.commonInstance = function() { + + this.instance.setDrawRange( + this.drawRange.start, + this.drawRange.count + ); + + this.groups.map( + function(group) { + this.instance.addGroup( + group.start, + group.count, + group.materialIndex + ) + }.bind(this) + ); +}; + +GameLib.D3.Geometry.Buffer.prototype.createInstance = function() { if (GameLib.Utils.Defined(this.instance)) { + this.commonInstance(); + /** * We already have our object - just call our parent and return */ - GameLib.Component.prototype.createInstance.call(this); + GameLib.D3.Geometry.prototype.createInstance.call(this); return; } - /** - * Then we convert to the new BufferGeometry type - */ this.instance = new THREE.BufferGeometry(); + this.commonInstance(); + /** * Setup mesh vertices positions * @type {Float32Array} @@ -116,7 +118,6 @@ GameLib.D3.BufferGeometry.prototype.createInstance = function() { [] ) ); - this.instance.addAttribute('position', new THREE.BufferAttribute(vertices, 3)); /** @@ -193,10 +194,9 @@ GameLib.D3.BufferGeometry.prototype.createInstance = function() { ) ); this.instance.addAttribute('normal', new THREE.BufferAttribute(normals, 3 )); - - this.instance.normalizeNormals(); - + //TODO: check below i don't do this - i used to but i don't think i should + //this.instance.normalizeNormals(); //this.instance.computeVertexNormals(); /** @@ -245,22 +245,17 @@ GameLib.D3.BufferGeometry.prototype.createInstance = function() { 0 ); - GameLib.Component.prototype.createInstance.call(this); + GameLib.D3.Geometry.prototype.createInstance.call(this); }; -GameLib.D3.BufferGeometry.prototype.updateInstance = function(property) { +GameLib.D3.Geometry.Buffer.prototype.updateInstance = function(property) { if (GameLib.Utils.UndefinedOrNull(this.instance)) { console.warn('no buffer geometry instance'); return; } - if (property === 'name') { - this.instance.name = this.name; - return; - } - if (property === 'faces') { console.warn('todo: faces setup'); return; @@ -271,26 +266,11 @@ GameLib.D3.BufferGeometry.prototype.updateInstance = function(property) { return; } - if (property === 'colors') { - console.warn('todo: colors setup'); - return; - } - if (property === 'attributes') { console.warn('todo: attributes setup'); return; } - if (property === 'boundingBox') { - console.warn('boundingBox is read only'); - return; - } - - if (property === 'boundingSphere') { - console.warn('boundingSphere is read only'); - return; - } - if (property === 'drawRange') { this.instance.setDrawRange( this.drawRange.start, @@ -300,7 +280,19 @@ GameLib.D3.BufferGeometry.prototype.updateInstance = function(property) { } if (property === 'groups') { - console.warn('todo: groups setup'); + + this.instance.clearGroups(); + + this.groups.map( + function(group) { + this.instance.addGroup( + group.start, + group.count, + group.materialIndex + ) + }.bind(this) + ); + return; } @@ -314,45 +306,35 @@ GameLib.D3.BufferGeometry.prototype.updateInstance = function(property) { return; } + GameLib.D3.Geometry.prototype.updateInstance.call(this, property); + }; /** - * Converts a GameLib.D3.BufferGeometry to a GameLib.D3.API.BufferGeometry - * @returns {GameLib.D3.API.BufferGeometry} + * Converts a GameLib.D3.Geometry.Buffer to a GameLib.D3.API.Geometry.Buffer + * @returns {GameLib.D3.API.Geometry.Buffer} */ -GameLib.D3.BufferGeometry.prototype.toApiObject = function() { +GameLib.D3.Geometry.Buffer.prototype.toApiObject = function() { - var apiBufferGeometry = new GameLib.D3.API.BufferGeometry( - this.id, - this.name, - this.bufferGeometryType, - GameLib.Utils.IdOrNull(this.parentEntity), - this.faces.map( - function(face) { - return face.toApiObject(); - } - ), - this.vertices.map( - function (vertex) { - return vertex.toApiObject(); - } - ), - this.colors.map( - function(color) { - return color.toApiObject(); - } - ), - null, //fuck attributes - this.boundingBox.toApiObject(), - this.boundingSphere.toApiObject(), + var apiGeometry = GameLib.D3.Geometry.prototype.toApiObject.call(this); + + /** + * Right now we don't store attributes and index, also we don't use morphAttributes yet. + * @type {GameLib.D3.API.Geometry.Buffer} + */ + + var apiBufferGeometry = new GameLib.D3.API.Geometry.Buffer( + + apiGeometry, + null, //attributes, this.drawRange.toApiObject(), this.groups.map( function(group){ return group.toApiObject() } ), - null, //fuck index - null //fuck morphAttributes + null, //index, + null //morphAttributes ); return apiBufferGeometry; @@ -360,9 +342,9 @@ GameLib.D3.BufferGeometry.prototype.toApiObject = function() { }; /** - * Update GameLib.D3.BufferGeometry from instance + * Update GameLib.D3.Geometry.Buffer from instance */ -GameLib.D3.BufferGeometry.prototype.updateFromInstance = function() { +GameLib.D3.Geometry.Buffer.prototype.updateFromInstance = function() { var vertices = this.instance.getAttribute('position').array; @@ -454,41 +436,87 @@ GameLib.D3.BufferGeometry.prototype.updateFromInstance = function() { /** * Clears all groups */ -GameLib.D3.BufferGeometry.prototype.clearGroups = function() { +GameLib.D3.Geometry.Buffer.prototype.clearGroups = function() { this.instance.clearGroups(); this.groups = this.instance.groups; }; /** - * Clears all groups + * Clears all material groups and makes the geometry use a single material only */ -GameLib.D3.BufferGeometry.prototype.singleMaterial = function() { +GameLib.D3.Geometry.Buffer.prototype.toSingleMaterial = function() { - this.instance.clearGroups(); + if (this.instance && this.instance.index) { - this.instance.addGroup( - 0, - this.instance.index.count, - 0 - ); + this.instance.clearGroups(); - this.groups = this.instance.groups; + this.instance.addGroup( + 0, + this.instance.index.count, + 0 + ); + + this.groups = this.instance.groups; + + } else { + console.warn('this is not an indexed buffer geometry or geometry not loaded'); + } + +}; + + +/** + * To non-index buffer geometry + */ +GameLib.D3.Geometry.Buffer.prototype.toNonIndexed = function() { + console.warn('not yet tested fully'); + + this.instance = this.instance.toNonIndexed(); + + this.parentMesh.instance.geometry = this.instance; + +// this.updateFromInstance(); +}; + +GameLib.D3.Geometry.Buffer.prototype.applyPositionRotationScale = function() { + + console.warn('todo and test'); + /** + * + You want to get the world position of a mesh's geometry, taking into consideration the mesh's transform matrix, mesh.matrix. + Also, your mesh geometry is THREE.BufferGeometry. + + Here is the pattern to follow: + + mesh = new THREE.Mesh( geometry, material ); + mesh.position.set( 10, 10, 10 ); + mesh.rotation.set( - Math.PI / 2, 0, 0 ); + mesh.scale.set( 1, 1, 1 ); + scene.add( mesh ); + + mesh.updateMatrix(); // make sure the mesh's matrix is updated + + var vec = new THREE.Vector3(); + var attribute = mesh.geometry.attributes.position; // we want the position data + var index = 1; // index is zero-based, so this the the 2nd vertex + + vec.fromAttribute( attribute, index ); // extract the x,y,z coordinates + + vec.applyMatrix4( mesh.matrix ); // apply the mesh's matrix transform + */ }; /** - * Compute Vertex Normals + * Buffer geometry needs to do more work after updating vertex normals */ -GameLib.D3.BufferGeometry.prototype.computeVertexNormals = function() { - +GameLib.D3.Geometry.Buffer.prototype.computeVertexNormals = function() { this.instance.computeVertexNormals(); - + // var attribute = this.instance.getAttribute('normal'); + // attribute.setDynamic(true); }; -/** - * Compute Vertex Normals - */ -GameLib.D3.BufferGeometry.prototype.toNonIndexed = function() { - - this.instance.toNonIndexed(); - +GameLib.D3.Geometry.Buffer.prototype.normalizeNormals = function() { + this.instance.normalizeNormals(); + // var attribute = this.instance.getAttribute('normal'); + // attribute.setDynamic(true); }; \ No newline at end of file diff --git a/src/game-lib-d3-geometry-buffer-box.js b/src/game-lib-d3-geometry-buffer-box.js new file mode 100644 index 0000000..7d9b713 --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-box.js @@ -0,0 +1,108 @@ +/** + * GameLib.D3.Geometry.Buffer.Box + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferBox + * @constructor + */ +GameLib.D3.Geometry.Buffer.Box = function( + graphics, + apiGeometryBufferBox +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferBox)) { + apiGeometryBufferBox = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_BOX + }; + } + + GameLib.D3.API.Geometry.Buffer.Box.call( + this, + apiGeometryBufferBox, + apiGeometryBufferBox.width, + apiGeometryBufferBox.height, + apiGeometryBufferBox.depth, + apiGeometryBufferBox.widthSegments, + apiGeometryBufferBox.heightSegments, + apiGeometryBufferBox.depthSegments + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferBox + ); + +}; + +GameLib.D3.Geometry.Buffer.Box.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.Box.prototype.constructor = GameLib.D3.Geometry.Buffer.Box; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.Box.prototype.createInstance = function() { + + this.instance = new THREE.BoxBufferGeometry( + this.width, + this.height, + this.depth, + this.widthSegments, + this.heightSegments, + this.depthSegments + ); + + this.instance.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.Box.prototype.updateInstance = function(property) { + + if ( + property === 'width' || + property === 'height' || + property === 'depth' || + property === 'widthSegments' || + property === 'heightSegments' || + property === 'depthSegments' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + } + + return; + } + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.Box to a GameLib.D3.API.Geometry.Buffer.Box + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.Box.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferBox = new GameLib.D3.API.Geometry.Buffer.Box( + apiBufferGeometry, + this.width, + this.height, + this.depth, + this.widthSegments, + this.heightSegments, + this.depthSegments + ); + + return apiGeometryBufferBox; +}; diff --git a/src/game-lib-d3-geometry-buffer-circle.js b/src/game-lib-d3-geometry-buffer-circle.js new file mode 100644 index 0000000..a15b291 --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-circle.js @@ -0,0 +1,110 @@ +/** + * GameLib.D3.Geometry.Buffer.Circle + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferCircle + * @constructor + */ +GameLib.D3.Geometry.Buffer.Circle = function( + graphics, + apiGeometryBufferCircle +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferCircle)) { + apiGeometryBufferCircle = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CIRCLE + }; + } + + GameLib.D3.API.Geometry.Buffer.Circle.call( + this, + apiGeometryBufferCircle, + apiGeometryBufferCircle.radius, + apiGeometryBufferCircle.segments, + apiGeometryBufferCircle.thetaStart, + apiGeometryBufferCircle.thetaLength + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferCircle + ); + +}; + +GameLib.D3.Geometry.Buffer.Circle.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.Circle.prototype.constructor = GameLib.D3.Geometry.Buffer.Circle; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.Circle.prototype.createInstance = function() { + + this.instance = new THREE.CircleBufferGeometry( + this.radius, + this.segments, + this.thetaStart, + this.thetaLength + ); + + /** + * The instance doesn't have any groups associated with it - so I just create the default single material group + */ + this.toSingleMaterial(); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.Circle.prototype.updateInstance = function(property) { + + if ( + property === 'radius' || + property === 'segments' || + property === 'thetaStart' || + property === 'thetaLength' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.Circle to a GameLib.D3.API.Geometry.Buffer.Circle + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.Circle.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferCircle = new GameLib.D3.API.Geometry.Buffer.Circle( + apiBufferGeometry, + this.radius, + this.segments, + this.thetaStart, + this.thetaLength + ); + + return apiGeometryBufferCircle; +}; diff --git a/src/game-lib-d3-geometry-buffer-cone.js b/src/game-lib-d3-geometry-buffer-cone.js new file mode 100644 index 0000000..5501674 --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-cone.js @@ -0,0 +1,117 @@ +/** + * GameLib.D3.Geometry.Buffer.Cone + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferCone + * @constructor + */ +GameLib.D3.Geometry.Buffer.Cone = function( + graphics, + apiGeometryBufferCone +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferCone)) { + apiGeometryBufferCone = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CONE + }; + } + + GameLib.D3.API.Geometry.Buffer.Cone.call( + this, + apiGeometryBufferCone, + apiGeometryBufferCone.radius, + apiGeometryBufferCone.height, + apiGeometryBufferCone.radialSegments, + apiGeometryBufferCone.heightSegments, + apiGeometryBufferCone.openEnded, + apiGeometryBufferCone.thetaStart, + apiGeometryBufferCone.thetaLength + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferCone + ); + +}; + +GameLib.D3.Geometry.Buffer.Cone.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.Cone.prototype.constructor = GameLib.D3.Geometry.Buffer.Cone; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.Cone.prototype.createInstance = function() { + + this.instance = new THREE.ConeBufferGeometry( + this.radius, + this.height, + this.radialSegments, + this.heightSegments, + this.openEnded, + this.thetaStart, + this.thetaLength + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.Cone.prototype.updateInstance = function(property) { + + if ( + property === 'radius' || + property === 'height' || + property === 'radialSegments' || + property === 'heightSegments' || + property === 'openEnded' || + property === 'thetaStart' || + property === 'thetaLength' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.Cone to a GameLib.D3.API.Geometry.Buffer.Cone + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.Cone.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferCone = new GameLib.D3.API.Geometry.Buffer.Cone( + apiBufferGeometry, + this.radius, + this.height, + this.radialSegments, + this.heightSegments, + this.openEnded, + this.thetaStart, + this.thetaLength + ); + + return apiGeometryBufferCone; +}; diff --git a/src/game-lib-d3-geometry-buffer-cylinder.js b/src/game-lib-d3-geometry-buffer-cylinder.js new file mode 100644 index 0000000..63c7c79 --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-cylinder.js @@ -0,0 +1,121 @@ +/** + * GameLib.D3.Geometry.Buffer.Cylinder + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferCylinder + * @constructor + */ +GameLib.D3.Geometry.Buffer.Cylinder = function( + graphics, + apiGeometryBufferCylinder +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferCylinder)) { + apiGeometryBufferCylinder = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CYLINDER + }; + } + + GameLib.D3.API.Geometry.Buffer.Cylinder.call( + this, + apiGeometryBufferCylinder, + apiGeometryBufferCylinder.radiusTop, + apiGeometryBufferCylinder.radiusBottom, + apiGeometryBufferCylinder.height, + apiGeometryBufferCylinder.radialSegments, + apiGeometryBufferCylinder.heightSegments, + apiGeometryBufferCylinder.openEnded, + apiGeometryBufferCylinder.thetaStart, + apiGeometryBufferCylinder.thetaLength + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferCylinder + ); + +}; + +GameLib.D3.Geometry.Buffer.Cylinder.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.Cylinder.prototype.constructor = GameLib.D3.Geometry.Buffer.Cylinder; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.Cylinder.prototype.createInstance = function() { + + this.instance = new THREE.CylinderBufferGeometry( + this.radiusTop, + this.radiusBottom, + this.height, + this.radialSegments, + this.heightSegments, + this.openEnded, + this.thetaStart, + this.thetaLength + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.Cylinder.prototype.updateInstance = function(property) { + + if ( + property === 'radiusTop' || + property === 'radiusBottom' || + property === 'height' || + property === 'radialSegments' || + property === 'heightSegments' || + property === 'openEnded' || + property === 'thetaStart' || + property === 'thetaLength' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.Cylinder to a GameLib.D3.API.Geometry.Buffer.Cylinder + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.Cylinder.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferCylinder = new GameLib.D3.API.Geometry.Buffer.Cylinder( + apiBufferGeometry, + this.radiusTop, + this.radiusBottom, + this.height, + this.radialSegments, + this.heightSegments, + this.openEnded, + this.thetaStart, + this.thetaLength + ); + + return apiGeometryBufferCylinder; +}; diff --git a/src/game-lib-d3-geometry-buffer-dodecahedron.js b/src/game-lib-d3-geometry-buffer-dodecahedron.js new file mode 100644 index 0000000..93a54f0 --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-dodecahedron.js @@ -0,0 +1,103 @@ +/** + * GameLib.D3.Geometry.Buffer.Dodecahedron + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferDodecahedron + * @constructor + */ +GameLib.D3.Geometry.Buffer.Dodecahedron = function( + graphics, + apiGeometryBufferDodecahedron +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferDodecahedron)) { + apiGeometryBufferDodecahedron = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_DODECAHEDRON + }; + } + + GameLib.D3.API.Geometry.Buffer.Dodecahedron.call( + this, + apiGeometryBufferDodecahedron, + apiGeometryBufferDodecahedron.radius, + apiGeometryBufferDodecahedron.detail + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferDodecahedron + ); + +}; + +GameLib.D3.Geometry.Buffer.Dodecahedron.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.Dodecahedron.prototype.constructor = GameLib.D3.Geometry.Buffer.Dodecahedron; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.Dodecahedron.prototype.createInstance = function() { + + this.instance = new THREE.DodecahedronBufferGeometry( + this.radius, + this.detail + ); + + this.instance.addGroup( + 0, + this.instance.attributes.position.count, + 0 + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.Dodecahedron.prototype.updateInstance = function(property) { + + if ( + property === 'radius' || + property === 'detail' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.Dodecahedron to a GameLib.D3.API.Geometry.Buffer.Dodecahedron + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.Dodecahedron.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferDodecahedron = new GameLib.D3.API.Geometry.Buffer.Dodecahedron( + apiBufferGeometry, + this.radius, + this.detail + ); + + return apiGeometryBufferDodecahedron; +}; diff --git a/src/game-lib-d3-geometry-buffer-extrude.js b/src/game-lib-d3-geometry-buffer-extrude.js new file mode 100644 index 0000000..1363442 --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-extrude.js @@ -0,0 +1,146 @@ +/** + * GameLib.D3.Geometry.Buffer.Extrude + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferExtrude + * @constructor + */ +GameLib.D3.Geometry.Buffer.Extrude = function( + graphics, + apiGeometryBufferExtrude +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferExtrude)) { + apiGeometryBufferExtrude = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_EXTRUDE + }; + } + + GameLib.D3.API.Geometry.Buffer.Extrude.call( + this, + apiGeometryBufferExtrude, + apiGeometryBufferExtrude.shapes, + apiGeometryBufferExtrude.curveSegments, + apiGeometryBufferExtrude.steps, + apiGeometryBufferExtrude.amount, + apiGeometryBufferExtrude.bevelEnabled, + apiGeometryBufferExtrude.bevelThickness, + apiGeometryBufferExtrude.bevelSize, + apiGeometryBufferExtrude.bevelSegments, + apiGeometryBufferExtrude.extrudePath, + apiGeometryBufferExtrude.frames, + apiGeometryBufferExtrude.UVGenerator + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferExtrude + ); + +}; + +GameLib.D3.Geometry.Buffer.Extrude.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.Extrude.prototype.constructor = GameLib.D3.Geometry.Buffer.Extrude; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.Extrude.prototype.createInstance = function() { + + if (this.shapes.length === 0) { + console.warn('shapes are not ready for this instance'); + return; + } + + this.instance = new THREE.ExtrudeBufferGeometry( + this.shapes.map( + function(shape) { + return shape.instance; + } + ), + { + curveSegments : this.curveSegments, + steps : this.steps, + amount : this.amount, + bevelEnabled : this.bevelEnabled, + bevelThickness : this.bevelThickness, + bevelSize : this.bevelSize, + bevelSegments : this.bevelSegments + } + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.Extrude.prototype.updateInstance = function(property) { + + if ( + property === 'shapes' || + property === 'curveSegments' || + property === 'steps' || + property === 'amount' || + property === 'bevelEnabled' || + property === 'bevelThickness' || + property === 'bevelSize' || + property === 'bevelSegments' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + console.warn('do other properties here'); + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.Extrude to a GameLib.D3.API.Geometry.Buffer.Extrude + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.Extrude.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferExtrude = new GameLib.D3.API.Geometry.Buffer.Extrude( + apiBufferGeometry, + this.shapes.map( + function(shape) { + return GameLib.Utils.IdOrNull(shape); + } + ), + this.curveSegments, + this.steps, + this.amount, + this.bevelEnabled, + this.bevelThickness, + this.bevelSize, + this.bevelSegments, + GameLib.Utils.IdOrNull(this.extrudePath), + this.frames.map(function(frame){ + return GameLib.Utils.IdOrNull(frame); + }), + GameLib.Utils.IdOrNull(this.UVGenerator) + ); + + return apiGeometryBufferExtrude; +}; diff --git a/src/game-lib-d3-geometry-buffer-icosahedron.js b/src/game-lib-d3-geometry-buffer-icosahedron.js new file mode 100644 index 0000000..88385e3 --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-icosahedron.js @@ -0,0 +1,103 @@ +/** + * GameLib.D3.Geometry.Buffer.Icosahedron + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferIcosahedron + * @constructor + */ +GameLib.D3.Geometry.Buffer.Icosahedron = function( + graphics, + apiGeometryBufferIcosahedron +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferIcosahedron)) { + apiGeometryBufferIcosahedron = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_ICOSAHEDRON + }; + } + + GameLib.D3.API.Geometry.Buffer.Icosahedron.call( + this, + apiGeometryBufferIcosahedron, + apiGeometryBufferIcosahedron.radius, + apiGeometryBufferIcosahedron.detail + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferIcosahedron + ); + +}; + +GameLib.D3.Geometry.Buffer.Icosahedron.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.Icosahedron.prototype.constructor = GameLib.D3.Geometry.Buffer.Icosahedron; + +/** + * Create Instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.Icosahedron.prototype.createInstance = function() { + + this.instance = new THREE.IcosahedronBufferGeometry( + this.radius, + this.detail + ); + + this.instance.addGroup( + 0, + this.instance.attributes.position.count, + 0 + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.Icosahedron.prototype.updateInstance = function(property) { + + if ( + property === 'radius' || + property === 'detail' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.Icosahedron to a GameLib.D3.API.Geometry.Buffer.Icosahedron + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.Icosahedron.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferIcosahedron = new GameLib.D3.API.Geometry.Buffer.Icosahedron( + apiBufferGeometry, + this.radius, + this.detail + ); + + return apiGeometryBufferIcosahedron; +}; diff --git a/src/game-lib-d3-geometry-buffer-lathe.js b/src/game-lib-d3-geometry-buffer-lathe.js new file mode 100644 index 0000000..966bb73 --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-lathe.js @@ -0,0 +1,118 @@ +/** + * GameLib.D3.Geometry.Buffer.Lathe + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferLathe + * @constructor + */ +GameLib.D3.Geometry.Buffer.Lathe = function( + graphics, + apiGeometryBufferLathe +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferLathe)) { + apiGeometryBufferLathe = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_LATHE + }; + } + + GameLib.D3.API.Geometry.Buffer.Lathe.call( + this, + apiGeometryBufferLathe, + apiGeometryBufferLathe.points, + apiGeometryBufferLathe.segments, + apiGeometryBufferLathe.phiStart, + apiGeometryBufferLathe.phiLength + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferLathe + ); + +}; + +GameLib.D3.Geometry.Buffer.Lathe.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.Lathe.prototype.constructor = GameLib.D3.Geometry.Buffer.Lathe; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.Lathe.prototype.createInstance = function() { + + this.instance = new THREE.LatheBufferGeometry( + this.points.map( + function(point) { + return point.instance; + } + ), + this.segments, + this.phiStart, + this.phiLength + ); + + /** + * The instance doesn't have any groups associated with it - so I just create the default single material group + */ + this.toSingleMaterial(); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.Lathe.prototype.updateInstance = function(property) { + + if ( + property === 'points' || + property === 'segments' || + property === 'phiStart' || + property === 'phiLength' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.Lathe to a GameLib.D3.API.Geometry.Buffer.Lathe + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.Lathe.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferLathe = new GameLib.D3.API.Geometry.Buffer.Lathe( + apiBufferGeometry, + this.points.map( + function(point) { + return point.toApiObject(); + } + ), + this.segments, + this.phiStart, + this.phiLength + ); + + return apiGeometryBufferLathe; +}; diff --git a/src/game-lib-d3-geometry-buffer-octahedron.js b/src/game-lib-d3-geometry-buffer-octahedron.js new file mode 100644 index 0000000..15e0a32 --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-octahedron.js @@ -0,0 +1,103 @@ +/** + * GameLib.D3.Geometry.Buffer.Octahedron + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferOctahedron + * @constructor + */ +GameLib.D3.Geometry.Buffer.Octahedron = function( + graphics, + apiGeometryBufferOctahedron +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferOctahedron)) { + apiGeometryBufferOctahedron = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_OCTAHEDRON + }; + } + + GameLib.D3.API.Geometry.Buffer.Octahedron.call( + this, + apiGeometryBufferOctahedron, + apiGeometryBufferOctahedron.radius, + apiGeometryBufferOctahedron.detail + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferOctahedron + ); + +}; + +GameLib.D3.Geometry.Buffer.Octahedron.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.Octahedron.prototype.constructor = GameLib.D3.Geometry.Buffer.Octahedron; + +/** + * Create Instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.Octahedron.prototype.createInstance = function() { + + this.instance = new THREE.OctahedronBufferGeometry( + this.radius, + this.detail + ); + + this.instance.addGroup( + 0, + this.instance.attributes.position.count, + 0 + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.Octahedron.prototype.updateInstance = function(property) { + + if ( + property === 'radius' || + property === 'detail' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.Octahedron to a GameLib.D3.API.Geometry.Buffer.Octahedron + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.Octahedron.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferOctahedron = new GameLib.D3.API.Geometry.Buffer.Octahedron( + apiBufferGeometry, + this.radius, + this.detail + ); + + return apiGeometryBufferOctahedron; +}; diff --git a/src/game-lib-d3-geometry-buffer-parametric.js b/src/game-lib-d3-geometry-buffer-parametric.js new file mode 100644 index 0000000..2292a5f --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-parametric.js @@ -0,0 +1,107 @@ +/** + * GameLib.D3.Geometry.Buffer.Parametric + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferParametric + * @constructor + */ +GameLib.D3.Geometry.Buffer.Parametric = function( + graphics, + apiGeometryBufferParametric +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferParametric)) { + apiGeometryBufferParametric = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PARAMETRIC + }; + } + + GameLib.D3.API.Geometry.Buffer.Parametric.call( + this, + apiGeometryBufferParametric, + apiGeometryBufferParametric.generatorFn, + apiGeometryBufferParametric.slices, + apiGeometryBufferParametric.stacks + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferParametric + ); + +}; + +GameLib.D3.Geometry.Buffer.Parametric.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.Parametric.prototype.constructor = GameLib.D3.Geometry.Buffer.Parametric; + +/** + * Create Instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.Parametric.prototype.createInstance = function() { + + this.instance = new THREE.ParametricBufferGeometry( + new Function('u', 'v', this.generatorFn).bind(this), + this.slices, + this.stacks + ); + + this.instance.addGroup( + 0, + this.instance.attributes.position.count, + 0 + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.Parametric.prototype.updateInstance = function(property) { + + if ( + property === 'generatorFn' || + property === 'slices' || + property === 'stacks' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.Parametric to a GameLib.D3.API.Geometry.Buffer.Parametric + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.Parametric.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferParametric = new GameLib.D3.API.Geometry.Buffer.Parametric( + apiBufferGeometry, + this.generatorFn, + this.slices, + this.stacks + ); + + return apiGeometryBufferParametric; +}; diff --git a/src/game-lib-d3-geometry-buffer-plane.js b/src/game-lib-d3-geometry-buffer-plane.js new file mode 100644 index 0000000..6e6ad23 --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-plane.js @@ -0,0 +1,100 @@ +/** + * GameLib.D3.Geometry.Buffer.Plane + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferPlane + * @constructor + */ +GameLib.D3.Geometry.Buffer.Plane = function( + graphics, + apiGeometryBufferPlane +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferPlane)) { + apiGeometryBufferPlane = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PLANE + }; + } + + GameLib.D3.API.Geometry.Buffer.Plane.call( + this, + apiGeometryBufferPlane, + apiGeometryBufferPlane.width, + apiGeometryBufferPlane.height, + apiGeometryBufferPlane.widthSegments, + apiGeometryBufferPlane.heightSegments + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferPlane + ); + +}; + +GameLib.D3.Geometry.Buffer.Plane.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.Plane.prototype.constructor = GameLib.D3.Geometry.Buffer.Plane; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.Plane.prototype.createInstance = function() { + + this.instance = new THREE.PlaneBufferGeometry( + this.width, + this.height, + this.widthSegments, + this.heightSegments + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.Plane.prototype.updateInstance = function(property) { + + if ( + property === 'width' || + property === 'height' || + property === 'widthSegments' || + property === 'heightSegments' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + } + + return; + } + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.Plane to a GameLib.D3.API.Geometry.Buffer.Plane + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.Plane.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferPlane = new GameLib.D3.API.Geometry.Buffer.Plane( + apiBufferGeometry, + this.width, + this.height, + this.widthSegments, + this.heightSegments + ); + + return apiGeometryBufferPlane; +}; diff --git a/src/game-lib-d3-geometry-buffer-polyhedron.js b/src/game-lib-d3-geometry-buffer-polyhedron.js new file mode 100644 index 0000000..e69b876 --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-polyhedron.js @@ -0,0 +1,116 @@ +/** + * GameLib.D3.Geometry.Buffer.Polyhedron + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferPolyhedron + * @constructor + */ +GameLib.D3.Geometry.Buffer.Polyhedron = function( + graphics, + apiGeometryBufferPolyhedron +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferPolyhedron)) { + apiGeometryBufferPolyhedron = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_POLYHEDRON + }; + } + + GameLib.D3.API.Geometry.Buffer.Polyhedron.call( + this, + apiGeometryBufferPolyhedron, + apiGeometryBufferPolyhedron.vertices, + apiGeometryBufferPolyhedron.indices, + apiGeometryBufferPolyhedron.radius, + apiGeometryBufferPolyhedron.detail + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferPolyhedron + ); + +}; + +GameLib.D3.Geometry.Buffer.Polyhedron.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.Polyhedron.prototype.constructor = GameLib.D3.Geometry.Buffer.Polyhedron; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.Polyhedron.prototype.createInstance = function() { + + this.instance = new THREE.PolyhedronBufferGeometry( + this.vertices.map( + function(vertex) { + return vertex.position.instance; + } + ), + this.indices.map( + function(index) { + return index.instance; + } + ), + this.radius, + this.detail + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.Polyhedron.prototype.updateInstance = function(property) { + + if ( + property === 'vertices' || + property === 'indices' || + property === 'radius' || + property === 'detail' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + } + + return; + } + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.Polyhedron to a GameLib.D3.API.Geometry.Buffer.Polyhedron + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.Polyhedron.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferPolyhedron = new GameLib.D3.API.Geometry.Buffer.Polyhedron( + apiBufferGeometry, + this.vertices.map( + function(vertex){ + return vertex.toApiObject(); + } + ), + this.indices.map( + function(index){ + return index.toApiObject(); + } + ), + this.radius, + this.detail + ); + + return apiGeometryBufferPolyhedron; +}; diff --git a/src/game-lib-d3-geometry-buffer-ring.js b/src/game-lib-d3-geometry-buffer-ring.js new file mode 100644 index 0000000..083f91b --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-ring.js @@ -0,0 +1,113 @@ +/** + * GameLib.D3.Geometry.Buffer.Ring + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferRing + * @constructor + */ +GameLib.D3.Geometry.Buffer.Ring = function( + graphics, + apiGeometryBufferRing +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferRing)) { + apiGeometryBufferRing = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_RING + }; + } + + GameLib.D3.API.Geometry.Buffer.Ring.call( + this, + apiGeometryBufferRing, + apiGeometryBufferRing.innerRadius, + apiGeometryBufferRing.outerRadius, + apiGeometryBufferRing.thetaSegments, + apiGeometryBufferRing.phiSegments, + apiGeometryBufferRing.thetaStart, + apiGeometryBufferRing.thetaLength + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferRing + ); + +}; + +GameLib.D3.Geometry.Buffer.Ring.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.Ring.prototype.constructor = GameLib.D3.Geometry.Buffer.Ring; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.Ring.prototype.createInstance = function() { + + this.instance = new THREE.RingBufferGeometry( + this.innerRadius, + this.outerRadius, + this.thetaSegments, + this.phiSegments, + this.thetaStart, + this.thetaLength + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.Ring.prototype.updateInstance = function(property) { + + if ( + property === 'innerRadius' || + property === 'outerRadius' || + property === 'thetaSegments' || + property === 'phiSegments' || + property === 'thetaStart' || + property === 'thetaLength' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.Ring to a GameLib.D3.API.Geometry.Buffer.Ring + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.Ring.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferRing = new GameLib.D3.API.Geometry.Buffer.Ring( + apiBufferGeometry, + this.innerRadius, + this.outerRadius, + this.thetaSegments, + this.phiSegments, + this.thetaStart, + this.thetaLength + ); + + return apiGeometryBufferRing; +}; diff --git a/src/game-lib-d3-geometry-buffer-shape.js b/src/game-lib-d3-geometry-buffer-shape.js new file mode 100644 index 0000000..e4974b3 --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-shape.js @@ -0,0 +1,112 @@ +/** + * GameLib.D3.Geometry.Buffer.Shape + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferShape + * @constructor + */ +GameLib.D3.Geometry.Buffer.Shape = function( + graphics, + apiGeometryBufferShape +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferShape)) { + apiGeometryBufferShape = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SHAPE + }; + } + + GameLib.D3.API.Geometry.Buffer.Shape.call( + this, + apiGeometryBufferShape, + apiGeometryBufferShape.shapes, + apiGeometryBufferShape.curveSegments + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferShape + ); + +}; + +GameLib.D3.Geometry.Buffer.Shape.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.Shape.prototype.constructor = GameLib.D3.Geometry.Buffer.Shape; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.Shape.prototype.createInstance = function() { + + if (this.shapes.length === 0) { + console.warn('shapes are not ready for this instance'); + return; + } + + this.instance = new THREE.ShapeBufferGeometry( + this.shapes.map( + function(shape) { + return shape.instance; + } + ), + this.curveSegments + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.Shape.prototype.updateInstance = function(property) { + + if ( + property === 'shapes' || + property === 'curveSegments' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + console.warn('do other properties here'); + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.Shape to a GameLib.D3.API.Geometry.Buffer.Shape + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.Shape.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferShape = new GameLib.D3.API.Geometry.Buffer.Shape( + apiBufferGeometry, + this.shapes.map( + function(shape) { + return GameLib.Utils.IdOrNull(shape); + } + ), + this.curveSegments + ); + + return apiGeometryBufferShape; +}; diff --git a/src/game-lib-d3-geometry-buffer-sphere.js b/src/game-lib-d3-geometry-buffer-sphere.js new file mode 100644 index 0000000..abfc34d --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-sphere.js @@ -0,0 +1,117 @@ +/** + * GameLib.D3.Geometry.Buffer.Sphere + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferSphere + * @constructor + */ +GameLib.D3.Geometry.Buffer.Sphere = function( + graphics, + apiGeometryBufferSphere +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferSphere)) { + apiGeometryBufferSphere = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SPHERE + }; + } + + GameLib.D3.API.Geometry.Buffer.Sphere.call( + this, + apiGeometryBufferSphere, + apiGeometryBufferSphere.radius, + apiGeometryBufferSphere.widthSegments, + apiGeometryBufferSphere.heightSegments, + apiGeometryBufferSphere.phiStart, + apiGeometryBufferSphere.phiLength, + apiGeometryBufferSphere.thetaStart, + apiGeometryBufferSphere.thetaLength + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferSphere + ); + +}; + +GameLib.D3.Geometry.Buffer.Sphere.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.Sphere.prototype.constructor = GameLib.D3.Geometry.Buffer.Sphere; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.Sphere.prototype.createInstance = function() { + + this.instance = new THREE.SphereBufferGeometry( + this.radius, + this.widthSegments, + this.heightSegments, + this.phiStart, + this.phiLength, + this.thetaStart, + this.thetaLength + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.Sphere.prototype.updateInstance = function(property) { + + if ( + property === 'radius' || + property === 'widthSegments' || + property === 'heightSegments' || + property === 'phiStart' || + property === 'phiLength' || + property === 'thetaStart' || + property === 'thetaLength' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.Sphere to a GameLib.D3.API.Geometry.Buffer.Sphere + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.Sphere.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferSphere = new GameLib.D3.API.Geometry.Buffer.Sphere( + apiBufferGeometry, + this.radius, + this.widthSegments, + this.heightSegments, + this.phiStart, + this.phiLength, + this.thetaStart, + this.thetaLength + ); + + return apiGeometryBufferSphere; +}; diff --git a/src/game-lib-d3-geometry-buffer-tetrahedron.js b/src/game-lib-d3-geometry-buffer-tetrahedron.js new file mode 100644 index 0000000..2246b2a --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-tetrahedron.js @@ -0,0 +1,103 @@ +/** + * GameLib.D3.Geometry.Buffer.Tetrahedron + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferTetrahedron + * @constructor + */ +GameLib.D3.Geometry.Buffer.Tetrahedron = function( + graphics, + apiGeometryBufferTetrahedron +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferTetrahedron)) { + apiGeometryBufferTetrahedron = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TETRAHEDRON + }; + } + + GameLib.D3.API.Geometry.Buffer.Tetrahedron.call( + this, + apiGeometryBufferTetrahedron, + apiGeometryBufferTetrahedron.radius, + apiGeometryBufferTetrahedron.detail + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferTetrahedron + ); + +}; + +GameLib.D3.Geometry.Buffer.Tetrahedron.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.Tetrahedron.prototype.constructor = GameLib.D3.Geometry.Buffer.Tetrahedron; + +/** + * Create Instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.Tetrahedron.prototype.createInstance = function() { + + this.instance = new THREE.TetrahedronBufferGeometry( + this.radius, + this.detail + ); + + this.instance.addGroup( + 0, + this.instance.attributes.position.count, + 0 + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.Tetrahedron.prototype.updateInstance = function(property) { + + if ( + property === 'radius' || + property === 'detail' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.Tetrahedron to a GameLib.D3.API.Geometry.Buffer.Tetrahedron + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.Tetrahedron.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferTetrahedron = new GameLib.D3.API.Geometry.Buffer.Tetrahedron( + apiBufferGeometry, + this.radius, + this.detail + ); + + return apiGeometryBufferTetrahedron; +}; diff --git a/src/game-lib-d3-geometry-buffer-text.js b/src/game-lib-d3-geometry-buffer-text.js new file mode 100644 index 0000000..67807f3 --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-text.js @@ -0,0 +1,142 @@ +/** + * GameLib.D3.Geometry.Buffer.Text + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferText + * @constructor + */ +GameLib.D3.Geometry.Buffer.Text = function( + graphics, + apiGeometryBufferText +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferText)) { + apiGeometryBufferText = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TEXT + }; + } + + GameLib.D3.API.Geometry.Buffer.Text.call( + this, + apiGeometryBufferText, + apiGeometryBufferText.text, + apiGeometryBufferText.font, + apiGeometryBufferText.size, + apiGeometryBufferText.height, + apiGeometryBufferText.curveSegments, + apiGeometryBufferText.bevelEnabled, + apiGeometryBufferText.bevelThickness, + apiGeometryBufferText.bevelSize, + apiGeometryBufferText.bevelSegments + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferText + ); + +}; + +GameLib.D3.Geometry.Buffer.Text.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.Text.prototype.constructor = GameLib.D3.Geometry.Buffer.Text; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.Text.prototype.createInstance = function() { + + if (!this.font || !this.font.instance) { + console.warn('font not ready for this instance'); + return; + } + + this.instance = new THREE.TextBufferGeometry( + this.text, + { + font : this.font.instance, + size : this.size, + curveSegments : this.curveSegments, + steps : this.steps, + amount : this.amount, + bevelEnabled : this.bevelEnabled, + bevelThickness : this.bevelThickness, + bevelSize : this.bevelSize, + bevelSegments : this.bevelSegments + } + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.Text.prototype.updateInstance = function(property) { + + if ( + property === 'text' || + property === 'font' || + property === 'size' || + property === 'height' || + property === 'curveSegments' || + property === 'bevelEnabled' || + property === 'bevelThickness' || + property === 'bevelSize' || + property === 'bevelSegments' + ) { + + /** + * Could be that the instance does not exist - because font was not ready + */ + if (this.instance) { + this.instance.dispose(); + } + + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + console.warn('do other properties here'); + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.Text to a GameLib.D3.API.Geometry.Buffer.Text + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.Text.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferText = new GameLib.D3.API.Geometry.Buffer.Text( + apiBufferGeometry, + this.text, + GameLib.Utils.IdOrNull(this.font), + this.size, + this.height, + this.curveSegments, + this.bevelEnabled, + this.bevelThickness, + this.bevelSize, + this.bevelSegments + ); + + return apiGeometryBufferText; +}; diff --git a/src/game-lib-d3-geometry-buffer-torus-knot.js b/src/game-lib-d3-geometry-buffer-torus-knot.js new file mode 100644 index 0000000..98ba012 --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-torus-knot.js @@ -0,0 +1,113 @@ +/** + * GameLib.D3.Geometry.Buffer.TorusKnot + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferTorusKnot + * @constructor + */ +GameLib.D3.Geometry.Buffer.TorusKnot = function( + graphics, + apiGeometryBufferTorusKnot +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferTorusKnot)) { + apiGeometryBufferTorusKnot = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS_KNOT + }; + } + + GameLib.D3.API.Geometry.Buffer.TorusKnot.call( + this, + apiGeometryBufferTorusKnot, + apiGeometryBufferTorusKnot.radius, + apiGeometryBufferTorusKnot.tube, + apiGeometryBufferTorusKnot.radialSegments, + apiGeometryBufferTorusKnot.tubularSegments, + apiGeometryBufferTorusKnot.p, + apiGeometryBufferTorusKnot.q + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferTorusKnot + ); + +}; + +GameLib.D3.Geometry.Buffer.TorusKnot.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.TorusKnot.prototype.constructor = GameLib.D3.Geometry.Buffer.TorusKnot; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.TorusKnot.prototype.createInstance = function() { + + this.instance = new THREE.TorusKnotBufferGeometry( + this.radius, + this.tube, + this.radialSegments, + this.tubularSegments, + this.p, + this.q + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.TorusKnot.prototype.updateInstance = function(property) { + + if ( + property === 'radius' || + property === 'tube' || + property === 'radialSegments' || + property === 'tubularSegments' || + property === 'p' || + property === 'q' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.TorusKnot to a GameLib.D3.API.Geometry.Buffer.TorusKnot + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.TorusKnot.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferTorusKnot = new GameLib.D3.API.Geometry.Buffer.TorusKnot( + apiBufferGeometry, + this.radius, + this.tube, + this.radialSegments, + this.tubularSegments, + this.p, + this.q + ); + + return apiGeometryBufferTorusKnot; +}; diff --git a/src/game-lib-d3-geometry-buffer-torus.js b/src/game-lib-d3-geometry-buffer-torus.js new file mode 100644 index 0000000..31f96ad --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-torus.js @@ -0,0 +1,109 @@ +/** + * GameLib.D3.Geometry.Buffer.Torus + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferTorus + * @constructor + */ +GameLib.D3.Geometry.Buffer.Torus = function( + graphics, + apiGeometryBufferTorus +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferTorus)) { + apiGeometryBufferTorus = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS + }; + } + + GameLib.D3.API.Geometry.Buffer.Torus.call( + this, + apiGeometryBufferTorus, + apiGeometryBufferTorus.radius, + apiGeometryBufferTorus.tube, + apiGeometryBufferTorus.radialSegments, + apiGeometryBufferTorus.tubularSegments, + apiGeometryBufferTorus.arc + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferTorus + ); + +}; + +GameLib.D3.Geometry.Buffer.Torus.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.Torus.prototype.constructor = GameLib.D3.Geometry.Buffer.Torus; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.Torus.prototype.createInstance = function() { + + this.instance = new THREE.TorusBufferGeometry( + this.radius, + this.tube, + this.radialSegments, + this.tubularSegments, + this.arc + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.Torus.prototype.updateInstance = function(property) { + + if ( + property === 'radius' || + property === 'tube' || + property === 'radialSegments' || + property === 'tubularSegments' || + property === 'arc' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.Torus to a GameLib.D3.API.Geometry.Buffer.Torus + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.Torus.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferTorus = new GameLib.D3.API.Geometry.Buffer.Torus( + apiBufferGeometry, + this.radius, + this.tube, + this.radialSegments, + this.tubularSegments, + this.arc + ); + + return apiGeometryBufferTorus; +}; diff --git a/src/game-lib-d3-geometry-buffer-tube.js b/src/game-lib-d3-geometry-buffer-tube.js new file mode 100644 index 0000000..144d5d2 --- /dev/null +++ b/src/game-lib-d3-geometry-buffer-tube.js @@ -0,0 +1,109 @@ +/** + * GameLib.D3.Geometry.Buffer.Tube + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryBufferTube + * @constructor + */ +GameLib.D3.Geometry.Buffer.Tube = function( + graphics, + apiGeometryBufferTube +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryBufferTube)) { + apiGeometryBufferTube = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TUBE + }; + } + + GameLib.D3.API.Geometry.Buffer.Tube.call( + this, + apiGeometryBufferTube, + apiGeometryBufferTube.path, + apiGeometryBufferTube.tubularSegments, + apiGeometryBufferTube.radius, + apiGeometryBufferTube.radialSegments, + apiGeometryBufferTube.closed + ); + + GameLib.D3.Geometry.Buffer.call( + this, + this.graphics, + apiGeometryBufferTube + ); + +}; + +GameLib.D3.Geometry.Buffer.Tube.prototype = Object.create(GameLib.D3.Geometry.Buffer.prototype); +GameLib.D3.Geometry.Buffer.Tube.prototype.constructor = GameLib.D3.Geometry.Buffer.Tube; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Buffer.Tube.prototype.createInstance = function() { + + this.instance = new THREE.TubeBufferGeometry( + this.path.instance, + this.tubularSegments, + this.radius, + this.radialSegments, + this.closed + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Buffer.Tube.prototype.updateInstance = function(property) { + + if ( + property === 'path' || + property === 'tubularSegments' || + property === 'radius' || + property === 'radialSegments' || + property === 'closed' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Buffer.Tube to a GameLib.D3.API.Geometry.Buffer.Tube + * @returns {GameLib.D3.API.Geometry.Buffer} + */ +GameLib.D3.Geometry.Buffer.Tube.prototype.toApiObject = function() { + + var apiBufferGeometry = GameLib.D3.Geometry.Buffer.prototype.toApiObject.call(this); + + var apiGeometryBufferTube = new GameLib.D3.API.Geometry.Buffer.Tube( + apiBufferGeometry, + GameLib.Utils.IdOrNull(this.path), + this.tubularSegments, + this.radius, + this.radialSegments, + this.closed + ); + + return apiGeometryBufferTube; +}; diff --git a/src/game-lib-d3-geometry-normal-a.js b/src/game-lib-d3-geometry-normal-a.js new file mode 100644 index 0000000..12fb25c --- /dev/null +++ b/src/game-lib-d3-geometry-normal-a.js @@ -0,0 +1,471 @@ +/** + * GameLib.D3.Geometry.Normal + * @param graphics + * @param apiNormalGeometry + * @property geometryType + * @constructor + */ +GameLib.D3.Geometry.Normal = function( + graphics, + apiNormalGeometry +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiNormalGeometry)) { + apiNormalGeometry = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL + }; + } + + GameLib.D3.API.Geometry.Normal.call( + this, + apiNormalGeometry, + apiNormalGeometry.colors, + apiNormalGeometry.lineDistances, + apiNormalGeometry.morphTargets, + apiNormalGeometry.morphNormals, + apiNormalGeometry.skinWeights, + apiNormalGeometry.skinIndices, + apiNormalGeometry.verticesNeedsUpdate, + apiNormalGeometry.elementsNeedUpdate, + apiNormalGeometry.uvsNeedUpdate, + apiNormalGeometry.normalsNeedUpdate, + apiNormalGeometry.colorsNeedUpdate, + apiNormalGeometry.groupsNeedUpdate, + apiNormalGeometry.lineDistancesNeedUpdate + ); + + this.colors = this.colors.map( + function(color) { + return new GameLib.Color( + this.graphics, + color + ) + }.bind(this) + ); + + this.skinWeights = this.skinWeights.map( + function(skinWeight) { + return new GameLib.Vector4( + this.graphics, + skinWeight, + this + ) + }.bind(this) + ); + + this.skinIndices = this.skinIndices.map( + function(skinIndex) { + return new GameLib.Vector4( + this.graphics, + skinIndex, + this + ) + }.bind(this) + ); + + GameLib.D3.Geometry.call( + this, + this.graphics, + this + ); +}; + +GameLib.D3.Geometry.Normal.prototype = Object.create(GameLib.D3.Geometry.prototype); +GameLib.D3.Geometry.Normal.prototype.constructor = GameLib.D3.Geometry.Normal; + +GameLib.D3.Geometry.Normal.prototype.createInstance = function() { + + if (GameLib.Utils.Defined(this.instance)) { + + /** + * We already have our object - just call our parent and return + */ + GameLib.D3.Geometry.prototype.createInstance.call(this); + + return; + } + + this.instance = new THREE.Geometry(); + + /** + * Setup colors + */ + this.instance.colors = this.colors.map( + function(color) { + return color.instance; + } + ); + + /** + * Setup faces + */ + this.applyToInstance('faces'); + + /** + * Setup line distances - we let three calculate it and then update our information + */ + this.instance.computeLineDistances(); + this.lineDistances = this.instance.lineDistances; + + /** + * Some more stuff + */ + if (this.morphTargets && this.morphTargets.length > 0) { + this.instance.morphTargets = this.morphTargets; + } + + if (this.morphNormals && this.morphNormals.length > 0) { + this.instance.morphNormals = this.morphNormals; + } + + if (this.skinWeights && this.skinWeights.length > 0) { + this.instance.skinWeights = this.skinWeights.map( + function(skinWeight) { + return skinWeight.instance; + } + ); + } + + if (this.skinIndices && this.skinIndices.length > 0) { + this.instance.skinIndices = this.skinIndices.map( + function(skinIndex) { + return skinIndex.instance; + } + ); + } + + /** + * Setup vertices + */ + this.applyToInstance('vertices'); + + //TODO: Below is actually for blender data - fix this server side and then remove this eventually + //this.instance.computeFaceNormals(); + //this.instance.computeVertexNormals(); + + GameLib.D3.Geometry.prototype.createInstance.call(this); +}; + +GameLib.D3.Geometry.Normal.prototype.updateInstance = function(property) { + + if (GameLib.Utils.UndefinedOrNull(this.instance)) { + console.warn('no geometry instance'); + return; + } + + if (property === 'colors') { + this.instance.colors = this.colors.map( + function(color) { + return color.instance; + } + ); + this.instance.colorsNeedUpdate = true; + return; + } + + if (property === 'faces') { + this.applyToInstance(property); + this.instance.elementsNeedUpdate = true; + this.instance.groupsNeedUpdate = true; + return; + } + + if (property === 'lineDistances') { + this.instance.lineDistances = this.lineDistances; + this.instance.lineDistancesNeedUpdate = true; + return; + } + + if (property === 'morphTargets') { + this.instance.morphTargets = this.morphTargets; + return; + } + + if (property === 'morphNormals') { + this.instance.morphNormals = this.morphNormals; + return; + } + + if (property === 'skinWeights') { + + if (this.skinWeights) { + this.instance.skinWeights = this.skinWeights.map( + function(skinWeight) { + return skinWeight.instance; + } + ) + } else { + console.warn('todo : check deleting skinweights'); + delete this.instance.skinWeights; + } + + return; + } + + if (property === 'skinIndices') { + + if (this.skinIndices) { + this.instance.skinIndices = this.skinIndices.map( + function(skinIndex) { + return skinIndex.instance; + } + ) + } else { + console.warn('todo : check deleting skinIndices'); + delete this.instance.skinIndices; + } + + return; + } + + if (property === 'vertices') { + this.applyToInstance(property); + this.instance.verticesNeedUpdate = true; + return; + } + + /** + * Manually trigger updates (and ignore our setting) + */ + if (property === 'verticesNeedsUpdate') { + this.instance.verticesNeedsUpdate = true; + this.verticesNeedUpdate = false; + } + + if (property === 'elementsNeedUpdate') { + this.instance.elementsNeedUpdate = true; + this.elementsNeedUpdate = false; + } + + if (property === 'uvsNeedUpdate') { + this.instance.uvsNeedUpdate = true; + this.uvsNeedUpdate = false; + } + + if (property === 'normalsNeedUpdate') { + this.instance.normalsNeedUpdate = true; + this.normalsNeedUpdate = false; + } + + if (property === 'colorsNeedUpdate') { + this.instance.colorsNeedUpdate = true; + this.colorsNeedUpdate = false; + } + + if (property === 'groupsNeedUpdate') { + this.instance.groupsNeedUpdate = true; + this.groupsNeedUpdate = false; + } + + if (property === 'lineDistancesNeedUpdate') { + this.instance.lineDistancesNeedUpdate = true; + this.lineDistancesNeedUpdate = false; + } + + GameLib.D3.Geometry.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal to a GameLib.D3.API.Geometry.Normal + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.prototype.toApiObject = function() { + + var apiGeometry = GameLib.D3.Geometry.prototype.toApiObject.call(this); + + var apiNormalGeometry = new GameLib.D3.API.Geometry.Normal( + apiGeometry, + this.colors.map( + function(color) { + return color.toApiObject(); + } + ), + this.lineDistances, + this.morphTargets, + this.morphNormals, + this.skinWeights.map( + function(skinWeight) { + return skinWeight.toApiObject(); + } + ), + this.skinIndices.map( + function(skinIndex) { + return skinIndex.toApiObject(); + } + ) + ); + + return apiNormalGeometry; +}; + +/** + * Update GameLib.D3.Geometry.Normal from instance + */ +GameLib.D3.Geometry.Normal.prototype.updateFromInstance = function() { + + var processed = 0; + + this.instance.faces.map(function(face, faceIndex){ + + processed++; + + if (processed % 100 === 0) { + console.log('processed ' + processed + ' faces'); + } + + this.faces.push( + new GameLib.D3.Face( + this.graphics, + new GameLib.D3.API.Face( + null, + null, + face.a, + face.b, + face.c, + face.materialIndex, + [[ + new GameLib.API.Vector2( + this.instance.faceVertexUvs[0][faceIndex][0].x, + this.instance.faceVertexUvs[0][faceIndex][0].y + ), + new GameLib.API.Vector2( + this.instance.faceVertexUvs[0][faceIndex][1].x, + this.instance.faceVertexUvs[0][faceIndex][1].y + ), + new GameLib.API.Vector2( + this.instance.faceVertexUvs[0][faceIndex][2].x, + this.instance.faceVertexUvs[0][faceIndex][2].y + ) + ]], + new GameLib.Color( + this.graphics, + new GameLib.API.Color( + face.color.r, + face.color.g, + face.color.b + ) + ), + face.vertexColors.map(function(vertexColor){ + return new GameLib.Color( + this.graphics, + new GameLib.API.Color( + vertexColor.r, + vertexColor.g, + vertexColor.b + ) + ) + }.bind(this)), + face.vertexNormals.map(function(vertexNormal){ + return new GameLib.Vector3( + this.graphics, + new GameLib.API.Vector3( + vertexNormal.x, + vertexNormal.y, + vertexNormal.z + ) + ) + }.bind(this)), + new GameLib.Vector3( + this.graphics, + new GameLib.API.Vector3( + face.normal.x, + face.normal.y, + face.normal.z + ) + ) + ) + ) + ) + }.bind(this)); + + processed = 0; + + this.instance.vertices.map(function(vertex){ + + processed++; + + if (processed % 100 === 0) { + console.log('processed ' + processed + ' vertices'); + } + + this.vertices.push( + new GameLib.D3.Vertex( + this.graphics, + new GameLib.D3.API.Vertex( + new GameLib.Vector3( + this.graphics, + new GameLib.API.Vector3( + vertex.x, + vertex.y, + vertex.z + ) + ) + ) + ) + ) + + }.bind(this)); + +}; + +GameLib.D3.Geometry.Normal.prototype.applyToInstance = function(property) { + + if (property === 'faces') { + + this.faces = GameLib.Utils.SortFacesByMaterialIndex(this.faces); + + var standardUvs = []; + + /** + * Now setup each face and collect UV information during this process + */ + this.instance.faces = this.faces.map( + function (face) { + + if (face.uvs[0].length > 0) { + standardUvs.push( + face.uvs[0].map( + function (uv) { + return uv.instance; + } + ) + ); + } + + if (!face.instance) { + face.createInstance(this); + } + + return face.instance; + }.bind(this) + ); + + /** + * UV data - but only if it exists + */ + if (standardUvs.length > 0) { + this.instance.faceVertexUvs = [standardUvs]; + } + + return; + } + + if (property === 'vertices') { + this.instance.vertices = this.vertices.map( + function (vertex) { + return vertex.position.instance; + } + ); + } +}; + +/** + * Re-compute vertex normals + */ +GameLib.D3.Geometry.Normal.prototype.computeVertexNormals = function() { + console.log('re-computing vertex normals'); + this.instance.computeVertexNormals(); +}; \ No newline at end of file diff --git a/src/game-lib-d3-geometry-normal-box.js b/src/game-lib-d3-geometry-normal-box.js new file mode 100644 index 0000000..84dac4e --- /dev/null +++ b/src/game-lib-d3-geometry-normal-box.js @@ -0,0 +1,97 @@ +/** + * GameLib.D3.Geometry.Normal.Box + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalBox + * @constructor + */ +GameLib.D3.Geometry.Normal.Box = function( + graphics, + apiGeometryNormalBox +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalBox)) { + apiGeometryNormalBox = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_BOX + }; + } + + GameLib.D3.API.Geometry.Normal.Box.call( + this, + apiGeometryNormalBox, + apiGeometryNormalBox.width, + apiGeometryNormalBox.height, + apiGeometryNormalBox.depth, + apiGeometryNormalBox.widthSegments, + apiGeometryNormalBox.heightSegments, + apiGeometryNormalBox.depthSegments + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalBox + ); + +}; + +GameLib.D3.Geometry.Normal.Box.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Box.prototype.constructor = GameLib.D3.Geometry.Normal.Box; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Box.prototype.createInstance = function() { + + this.instance = new THREE.BoxGeometry( + this.width, + this.height, + this.depth, + this.widthSegments, + this.heightSegments, + this.depthSegments + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Box.prototype.updateInstance = function(property) { + + if ( + property === 'width' + ) { + this.createInstance(); + return; + } + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Box to a GameLib.D3.API.Geometry.Normal.Box + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Box.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalBox = new GameLib.D3.API.Geometry.Normal.Box( + apiNormalGeometry, + this.width, + this.height, + this.depth, + this.widthSegments, + this.heightSegments, + this.depthSegments + ); + + return apiGeometryNormalBox; +}; diff --git a/src/game-lib-d3-geometry-normal-circle.js b/src/game-lib-d3-geometry-normal-circle.js new file mode 100644 index 0000000..80c3989 --- /dev/null +++ b/src/game-lib-d3-geometry-normal-circle.js @@ -0,0 +1,105 @@ +/** + * GameLib.D3.Geometry.Normal.Circle + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalCircle + * @constructor + */ +GameLib.D3.Geometry.Normal.Circle = function( + graphics, + apiGeometryNormalCircle +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalCircle)) { + apiGeometryNormalCircle = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CIRCLE + }; + } + + GameLib.D3.API.Geometry.Normal.Circle.call( + this, + apiGeometryNormalCircle, + apiGeometryNormalCircle.radius, + apiGeometryNormalCircle.segments, + apiGeometryNormalCircle.thetaStart, + apiGeometryNormalCircle.thetaLength + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalCircle + ); + +}; + +GameLib.D3.Geometry.Normal.Circle.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Circle.prototype.constructor = GameLib.D3.Geometry.Normal.Circle; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Circle.prototype.createInstance = function() { + + this.instance = new THREE.CircleGeometry( + this.radius, + this.segments, + this.thetaStart, + this.thetaLength + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Circle.prototype.updateInstance = function(property) { + + if ( + property === 'radius' || + property === 'segments' || + property === 'thetaStart' || + property === 'thetaLength' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Circle to a GameLib.D3.API.Geometry.Normal.Circle + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Circle.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalCircle = new GameLib.D3.API.Geometry.Normal.Circle( + apiNormalGeometry, + this.radius, + this.segments, + this.thetaStart, + this.thetaLength + ); + + return apiGeometryNormalCircle; +}; diff --git a/src/game-lib-d3-geometry-normal-cone.js b/src/game-lib-d3-geometry-normal-cone.js new file mode 100644 index 0000000..c6bb848 --- /dev/null +++ b/src/game-lib-d3-geometry-normal-cone.js @@ -0,0 +1,117 @@ +/** + * GameLib.D3.Geometry.Normal.Cone + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalCone + * @constructor + */ +GameLib.D3.Geometry.Normal.Cone = function( + graphics, + apiGeometryNormalCone +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalCone)) { + apiGeometryNormalCone = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CONE + }; + } + + GameLib.D3.API.Geometry.Normal.Cone.call( + this, + apiGeometryNormalCone, + apiGeometryNormalCone.radius, + apiGeometryNormalCone.height, + apiGeometryNormalCone.radialSegments, + apiGeometryNormalCone.heightSegments, + apiGeometryNormalCone.openEnded, + apiGeometryNormalCone.thetaStart, + apiGeometryNormalCone.thetaLength + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalCone + ); + +}; + +GameLib.D3.Geometry.Normal.Cone.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Cone.prototype.constructor = GameLib.D3.Geometry.Normal.Cone; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Cone.prototype.createInstance = function() { + + this.instance = new THREE.ConeGeometry( + this.radius, + this.height, + this.radialSegments, + this.heightSegments, + this.openEnded, + this.thetaStart, + this.thetaLength + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Cone.prototype.updateInstance = function(property) { + + if ( + property === 'radius' || + property === 'height' || + property === 'radialSegments' || + property === 'heightSegments' || + property === 'openEnded' || + property === 'thetaStart' || + property === 'thetaLength' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Cone to a GameLib.D3.API.Geometry.Normal.Cone + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Cone.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalCone = new GameLib.D3.API.Geometry.Normal.Cone( + apiNormalGeometry, + this.radius, + this.height, + this.radialSegments, + this.heightSegments, + this.openEnded, + this.thetaStart, + this.thetaLength + ); + + return apiGeometryNormalCone; +}; diff --git a/src/game-lib-d3-geometry-normal-cylinder.js b/src/game-lib-d3-geometry-normal-cylinder.js new file mode 100644 index 0000000..e9b3114 --- /dev/null +++ b/src/game-lib-d3-geometry-normal-cylinder.js @@ -0,0 +1,121 @@ +/** + * GameLib.D3.Geometry.Normal.Cylinder + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalCylinder + * @constructor + */ +GameLib.D3.Geometry.Normal.Cylinder = function( + graphics, + apiGeometryNormalCylinder +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalCylinder)) { + apiGeometryNormalCylinder = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_CYLINDER + }; + } + + GameLib.D3.API.Geometry.Normal.Cylinder.call( + this, + apiGeometryNormalCylinder, + apiGeometryNormalCylinder.radiusTop, + apiGeometryNormalCylinder.radiusBottom, + apiGeometryNormalCylinder.height, + apiGeometryNormalCylinder.radialSegments, + apiGeometryNormalCylinder.heightSegments, + apiGeometryNormalCylinder.openEnded, + apiGeometryNormalCylinder.thetaStart, + apiGeometryNormalCylinder.thetaLength + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalCylinder + ); + +}; + +GameLib.D3.Geometry.Normal.Cylinder.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Cylinder.prototype.constructor = GameLib.D3.Geometry.Normal.Cylinder; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Cylinder.prototype.createInstance = function() { + + this.instance = new THREE.CylinderGeometry( + this.radiusTop, + this.radiusBottom, + this.height, + this.radialSegments, + this.heightSegments, + this.openEnded, + this.thetaStart, + this.thetaLength + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Cylinder.prototype.updateInstance = function(property) { + + if ( + property === 'radiusTop' || + property === 'radiusBottom' || + property === 'height' || + property === 'radialSegments' || + property === 'heightSegments' || + property === 'openEnded' || + property === 'thetaStart' || + property === 'thetaLength' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Cylinder to a GameLib.D3.API.Geometry.Normal.Cylinder + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Cylinder.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalCylinder = new GameLib.D3.API.Geometry.Normal.Cylinder( + apiNormalGeometry, + this.radiusTop, + this.radiusBottom, + this.height, + this.radialSegments, + this.heightSegments, + this.openEnded, + this.thetaStart, + this.thetaLength + ); + + return apiGeometryNormalCylinder; +}; diff --git a/src/game-lib-d3-geometry-normal-dodecahedron.js b/src/game-lib-d3-geometry-normal-dodecahedron.js new file mode 100644 index 0000000..0ceda1e --- /dev/null +++ b/src/game-lib-d3-geometry-normal-dodecahedron.js @@ -0,0 +1,97 @@ +/** + * GameLib.D3.Geometry.Normal.Dodecahedron + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalDodecahedron + * @constructor + */ +GameLib.D3.Geometry.Normal.Dodecahedron = function( + graphics, + apiGeometryNormalDodecahedron +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalDodecahedron)) { + apiGeometryNormalDodecahedron = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_DODECAHEDRON + }; + } + + GameLib.D3.API.Geometry.Normal.Dodecahedron.call( + this, + apiGeometryNormalDodecahedron, + apiGeometryNormalDodecahedron.radius, + apiGeometryNormalDodecahedron.detail + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalDodecahedron + ); + +}; + +GameLib.D3.Geometry.Normal.Dodecahedron.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Dodecahedron.prototype.constructor = GameLib.D3.Geometry.Normal.Dodecahedron; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Dodecahedron.prototype.createInstance = function() { + + this.instance = new THREE.DodecahedronGeometry( + this.radius, + this.detail + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Dodecahedron.prototype.updateInstance = function(property) { + + if ( + property === 'radius' || + property === 'detail' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Dodecahedron to a GameLib.D3.API.Geometry.Normal.Dodecahedron + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Dodecahedron.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalDodecahedron = new GameLib.D3.API.Geometry.Normal.Dodecahedron( + apiNormalGeometry, + this.radius, + this.detail + ); + + return apiGeometryNormalDodecahedron; +}; diff --git a/src/game-lib-d3-geometry-normal-edges.js b/src/game-lib-d3-geometry-normal-edges.js new file mode 100644 index 0000000..829d41e --- /dev/null +++ b/src/game-lib-d3-geometry-normal-edges.js @@ -0,0 +1,108 @@ +/** + * GameLib.D3.Geometry.Normal.Edges + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalEdges + * @constructor + */ +GameLib.D3.Geometry.Normal.Edges = function( + graphics, + apiGeometryNormalEdges +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalEdges)) { + apiGeometryNormalEdges = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EDGES + }; + } + + GameLib.D3.API.Geometry.Normal.Edges.call( + this, + apiGeometryNormalEdges, + apiGeometryNormalEdges.geometry, + apiGeometryNormalEdges.thresholdAngle + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalEdges + ); + +}; + +GameLib.D3.Geometry.Normal.Edges.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Edges.prototype.constructor = GameLib.D3.Geometry.Normal.Edges; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Edges.prototype.createInstance = function() { + + if (!this.geometry || !this.geometry.instance) { + console.warn('geometry not ready'); + return; + } + + this.instance = new THREE.EdgesGeometry( + this.geometry.instance, + this.thresholdAngle + ); + + console.log('edges instance created'); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Edges.prototype.updateInstance = function(property) { + + if ( + property === 'geometry' || + property === 'thresholdAngle' + ) { + /** + * Could be that geometry was not ready + */ + if (this.instance) { + this.instance.dispose(); + } + + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Edges to a GameLib.D3.API.Geometry.Normal.Edges + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Edges.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalEdges = new GameLib.D3.API.Geometry.Normal.Edges( + apiNormalGeometry, + GameLib.Utils.IdOrNull(this.geometry), + this.thresholdAngle + ); + + return apiGeometryNormalEdges; +}; diff --git a/src/game-lib-d3-geometry-normal-extrude.js b/src/game-lib-d3-geometry-normal-extrude.js new file mode 100644 index 0000000..a472058 --- /dev/null +++ b/src/game-lib-d3-geometry-normal-extrude.js @@ -0,0 +1,141 @@ +/** + * GameLib.D3.Geometry.Normal.Extrude + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalExtrude + * @constructor + */ +GameLib.D3.Geometry.Normal.Extrude = function( + graphics, + apiGeometryNormalExtrude +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalExtrude)) { + apiGeometryNormalExtrude = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_EXTRUDE + }; + } + + GameLib.D3.API.Geometry.Normal.Extrude.call( + this, + apiGeometryNormalExtrude, + apiGeometryNormalExtrude.shapes, + apiGeometryNormalExtrude.curveSegments, + apiGeometryNormalExtrude.steps, + apiGeometryNormalExtrude.amount, + apiGeometryNormalExtrude.bevelEnabled, + apiGeometryNormalExtrude.bevelThickness, + apiGeometryNormalExtrude.bevelSize, + apiGeometryNormalExtrude.bevelSegments, + apiGeometryNormalExtrude.extrudePath, + apiGeometryNormalExtrude.frames, + apiGeometryNormalExtrude.UVGenerator + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalExtrude + ); + +}; + +GameLib.D3.Geometry.Normal.Extrude.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Extrude.prototype.constructor = GameLib.D3.Geometry.Normal.Extrude; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Extrude.prototype.createInstance = function() { + + this.instance = new THREE.ExtrudeGeometry( + this.shapes.map( + function(shape) { + return shape.instance; + } + ), + { + curveSegments : this.curveSegments, + steps : this.steps, + amount : this.amount, + bevelEnabled : this.bevelEnabled, + bevelThickness : this.bevelThickness, + bevelSize : this.bevelSize, + bevelSegments : this.bevelSegments + } + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Extrude.prototype.updateInstance = function(property) { + + if ( + property === 'shapes' || + property === 'curveSegments' || + property === 'steps' || + property === 'amount' || + property === 'bevelEnabled' || + property === 'bevelThickness' || + property === 'bevelSize' || + property === 'bevelSegments' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + console.warn('do other properties here'); + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Extrude to a GameLib.D3.API.Geometry.Normal.Extrude + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Extrude.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalExtrude = new GameLib.D3.API.Geometry.Normal.Extrude( + apiNormalGeometry, + this.shapes.map( + function(shape) { + return GameLib.Utils.IdOrNull(shape); + } + ), + this.curveSegments, + this.steps, + this.amount, + this.bevelEnabled, + this.bevelThickness, + this.bevelSize, + this.bevelSegments, + GameLib.Utils.IdOrNull(this.extrudePath), + this.frames.map(function(frame){ + return GameLib.Utils.IdOrNull(frame); + }), + GameLib.Utils.IdOrNull(this.UVGenerator) + ); + + return apiGeometryNormalExtrude; +}; diff --git a/src/game-lib-d3-geometry-normal-icosahedron.js b/src/game-lib-d3-geometry-normal-icosahedron.js new file mode 100644 index 0000000..25ac793 --- /dev/null +++ b/src/game-lib-d3-geometry-normal-icosahedron.js @@ -0,0 +1,97 @@ +/** + * GameLib.D3.Geometry.Normal.Icosahedron + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalIcosahedron + * @constructor + */ +GameLib.D3.Geometry.Normal.Icosahedron = function( + graphics, + apiGeometryNormalIcosahedron +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalIcosahedron)) { + apiGeometryNormalIcosahedron = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_ICOSAHEDRON + }; + } + + GameLib.D3.API.Geometry.Normal.Icosahedron.call( + this, + apiGeometryNormalIcosahedron, + apiGeometryNormalIcosahedron.radius, + apiGeometryNormalIcosahedron.detail + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalIcosahedron + ); + +}; + +GameLib.D3.Geometry.Normal.Icosahedron.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Icosahedron.prototype.constructor = GameLib.D3.Geometry.Normal.Icosahedron; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Icosahedron.prototype.createInstance = function() { + + this.instance = new THREE.IcosahedronGeometry( + this.radius, + this.detail + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Icosahedron.prototype.updateInstance = function(property) { + + if ( + property === 'radius' || + property === 'detail' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Icosahedron to a GameLib.D3.API.Geometry.Normal.Icosahedron + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Icosahedron.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalIcosahedron = new GameLib.D3.API.Geometry.Normal.Icosahedron( + apiNormalGeometry, + this.radius, + this.detail + ); + + return apiGeometryNormalIcosahedron; +}; diff --git a/src/game-lib-d3-geometry-normal-lathe.js b/src/game-lib-d3-geometry-normal-lathe.js new file mode 100644 index 0000000..ab2882a --- /dev/null +++ b/src/game-lib-d3-geometry-normal-lathe.js @@ -0,0 +1,113 @@ +/** + * GameLib.D3.Geometry.Normal.Lathe + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalLathe + * @constructor + */ +GameLib.D3.Geometry.Normal.Lathe = function( + graphics, + apiGeometryNormalLathe +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalLathe)) { + apiGeometryNormalLathe = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_LATHE + }; + } + + GameLib.D3.API.Geometry.Normal.Lathe.call( + this, + apiGeometryNormalLathe, + apiGeometryNormalLathe.points, + apiGeometryNormalLathe.segments, + apiGeometryNormalLathe.phiStart, + apiGeometryNormalLathe.phiLength + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalLathe + ); + +}; + +GameLib.D3.Geometry.Normal.Lathe.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Lathe.prototype.constructor = GameLib.D3.Geometry.Normal.Lathe; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Lathe.prototype.createInstance = function() { + + this.instance = new THREE.LatheGeometry( + this.points.map( + function(point) { + return point.instance; + } + ), + this.segments, + this.phiStart, + this.phiLength + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Lathe.prototype.updateInstance = function(property) { + + if ( + property === 'points' || + property === 'segments' || + property === 'phiStart' || + property === 'phiLength' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Lathe to a GameLib.D3.API.Geometry.Normal.Lathe + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Lathe.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalLathe = new GameLib.D3.API.Geometry.Normal.Lathe( + apiNormalGeometry, + this.points.map( + function(point) { + return point.toApiObject(); + } + ), + this.segments, + this.phiStart, + this.phiLength + ); + + return apiGeometryNormalLathe; +}; diff --git a/src/game-lib-d3-geometry-normal-octahedron.js b/src/game-lib-d3-geometry-normal-octahedron.js new file mode 100644 index 0000000..5dc9546 --- /dev/null +++ b/src/game-lib-d3-geometry-normal-octahedron.js @@ -0,0 +1,97 @@ +/** + * GameLib.D3.Geometry.Normal.Octahedron + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalOctahedron + * @constructor + */ +GameLib.D3.Geometry.Normal.Octahedron = function( + graphics, + apiGeometryNormalOctahedron +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalOctahedron)) { + apiGeometryNormalOctahedron = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_OCTAHEDRON + }; + } + + GameLib.D3.API.Geometry.Normal.Octahedron.call( + this, + apiGeometryNormalOctahedron, + apiGeometryNormalOctahedron.radius, + apiGeometryNormalOctahedron.detail + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalOctahedron + ); + +}; + +GameLib.D3.Geometry.Normal.Octahedron.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Octahedron.prototype.constructor = GameLib.D3.Geometry.Normal.Octahedron; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Octahedron.prototype.createInstance = function() { + + this.instance = new THREE.OctahedronGeometry( + this.radius, + this.detail + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Octahedron.prototype.updateInstance = function(property) { + + if ( + property === 'radius' || + property === 'detail' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Octahedron to a GameLib.D3.API.Geometry.Normal.Octahedron + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Octahedron.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalOctahedron = new GameLib.D3.API.Geometry.Normal.Octahedron( + apiNormalGeometry, + this.radius, + this.detail + ); + + return apiGeometryNormalOctahedron; +}; diff --git a/src/game-lib-d3-geometry-normal-parametric.js b/src/game-lib-d3-geometry-normal-parametric.js new file mode 100644 index 0000000..e1df47b --- /dev/null +++ b/src/game-lib-d3-geometry-normal-parametric.js @@ -0,0 +1,101 @@ +/** + * GameLib.D3.Geometry.Normal.Parametric + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalParametric + * @constructor + */ +GameLib.D3.Geometry.Normal.Parametric = function( + graphics, + apiGeometryNormalParametric +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalParametric)) { + apiGeometryNormalParametric = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_PARAMETRIC + }; + } + + GameLib.D3.API.Geometry.Normal.Parametric.call( + this, + apiGeometryNormalParametric, + apiGeometryNormalParametric.generatorFn, + apiGeometryNormalParametric.slices, + apiGeometryNormalParametric.stacks + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalParametric + ); + +}; + +GameLib.D3.Geometry.Normal.Parametric.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Parametric.prototype.constructor = GameLib.D3.Geometry.Normal.Parametric; + +/** + * Create Instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Parametric.prototype.createInstance = function() { + + this.instance = new THREE.ParametricGeometry( + new Function('u', 'v', this.generatorFn).bind(this), + this.slices, + this.stacks + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Parametric.prototype.updateInstance = function(property) { + + if ( + property === 'generatorFn' || + property === 'slices' || + property === 'stacks' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Parametric to a GameLib.D3.API.Geometry.Normal.Parametric + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Parametric.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalParametric = new GameLib.D3.API.Geometry.Normal.Parametric( + apiNormalGeometry, + this.generatorFn, + this.slices, + this.stacks + ); + + return apiGeometryNormalParametric; +}; diff --git a/src/game-lib-d3-geometry-normal-plane.js b/src/game-lib-d3-geometry-normal-plane.js new file mode 100644 index 0000000..90779cf --- /dev/null +++ b/src/game-lib-d3-geometry-normal-plane.js @@ -0,0 +1,100 @@ +/** + * GameLib.D3.Geometry.Normal.Plane + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalPlane + * @constructor + */ +GameLib.D3.Geometry.Normal.Plane = function( + graphics, + apiGeometryNormalPlane +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalPlane)) { + apiGeometryNormalPlane = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_PLANE + }; + } + + GameLib.D3.API.Geometry.Normal.Plane.call( + this, + apiGeometryNormalPlane, + apiGeometryNormalPlane.width, + apiGeometryNormalPlane.height, + apiGeometryNormalPlane.widthSegments, + apiGeometryNormalPlane.heightSegments + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalPlane + ); + +}; + +GameLib.D3.Geometry.Normal.Plane.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Plane.prototype.constructor = GameLib.D3.Geometry.Normal.Plane; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Plane.prototype.createInstance = function() { + + this.instance = new THREE.PlaneGeometry( + this.width, + this.height, + this.widthSegments, + this.heightSegments + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Plane.prototype.updateInstance = function(property) { + + if ( + property === 'width' || + property === 'height' || + property === 'widthSegments' || + property === 'heightSegments' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + } + + return; + } + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Plane to a GameLib.D3.API.Geometry.Normal.Plane + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Plane.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalPlane = new GameLib.D3.API.Geometry.Normal.Plane( + apiNormalGeometry, + this.width, + this.height, + this.widthSegments, + this.heightSegments + ); + + return apiGeometryNormalPlane; +}; diff --git a/src/game-lib-d3-geometry-normal-polyhedron.js b/src/game-lib-d3-geometry-normal-polyhedron.js new file mode 100644 index 0000000..824f170 --- /dev/null +++ b/src/game-lib-d3-geometry-normal-polyhedron.js @@ -0,0 +1,116 @@ +/** + * GameLib.D3.Geometry.Normal.Polyhedron + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalPolyhedron + * @constructor + */ +GameLib.D3.Geometry.Normal.Polyhedron = function( + graphics, + apiGeometryNormalPolyhedron +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalPolyhedron)) { + apiGeometryNormalPolyhedron = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_POLYHEDRON + }; + } + + GameLib.D3.API.Geometry.Normal.Polyhedron.call( + this, + apiGeometryNormalPolyhedron, + apiGeometryNormalPolyhedron.vertices, + apiGeometryNormalPolyhedron.indices, + apiGeometryNormalPolyhedron.radius, + apiGeometryNormalPolyhedron.detail + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalPolyhedron + ); + +}; + +GameLib.D3.Geometry.Normal.Polyhedron.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Polyhedron.prototype.constructor = GameLib.D3.Geometry.Normal.Polyhedron; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Polyhedron.prototype.createInstance = function() { + + this.instance = new THREE.PolyhedronGeometry( + this.vertices.map( + function(vertex) { + return vertex.position.instance; + } + ), + this.indices.map( + function(index) { + return index.instance; + } + ), + this.radius, + this.detail + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Polyhedron.prototype.updateInstance = function(property) { + + if ( + property === 'vertices' || + property === 'indices' || + property === 'radius' || + property === 'detail' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + } + + return; + } + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Polyhedron to a GameLib.D3.API.Geometry.Normal.Polyhedron + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Polyhedron.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalPolyhedron = new GameLib.D3.API.Geometry.Normal.Polyhedron( + apiNormalGeometry, + this.vertices.map( + function(vertex){ + return vertex.toApiObject(); + } + ), + this.indices.map( + function(index){ + return index.toApiObject(); + } + ), + this.radius, + this.detail + ); + + return apiGeometryNormalPolyhedron; +}; diff --git a/src/game-lib-d3-geometry-normal-ring.js b/src/game-lib-d3-geometry-normal-ring.js new file mode 100644 index 0000000..60bb0cb --- /dev/null +++ b/src/game-lib-d3-geometry-normal-ring.js @@ -0,0 +1,113 @@ +/** + * GameLib.D3.Geometry.Normal.Ring + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalRing + * @constructor + */ +GameLib.D3.Geometry.Normal.Ring = function( + graphics, + apiGeometryNormalRing +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalRing)) { + apiGeometryNormalRing = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_RING + }; + } + + GameLib.D3.API.Geometry.Normal.Ring.call( + this, + apiGeometryNormalRing, + apiGeometryNormalRing.innerRadius, + apiGeometryNormalRing.outerRadius, + apiGeometryNormalRing.thetaSegments, + apiGeometryNormalRing.phiSegments, + apiGeometryNormalRing.thetaStart, + apiGeometryNormalRing.thetaLength + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalRing + ); + +}; + +GameLib.D3.Geometry.Normal.Ring.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Ring.prototype.constructor = GameLib.D3.Geometry.Normal.Ring; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Ring.prototype.createInstance = function() { + + this.instance = new THREE.RingGeometry( + this.innerRadius, + this.outerRadius, + this.thetaSegments, + this.phiSegments, + this.thetaStart, + this.thetaLength + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Ring.prototype.updateInstance = function(property) { + + if ( + property === 'innerRadius' || + property === 'outerRadius' || + property === 'thetaSegments' || + property === 'phiSegments' || + property === 'thetaStart' || + property === 'thetaLength' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Ring to a GameLib.D3.API.Geometry.Normal.Ring + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Ring.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalRing = new GameLib.D3.API.Geometry.Normal.Ring( + apiNormalGeometry, + this.innerRadius, + this.outerRadius, + this.thetaSegments, + this.phiSegments, + this.thetaStart, + this.thetaLength + ); + + return apiGeometryNormalRing; +}; diff --git a/src/game-lib-d3-geometry-normal-shape.js b/src/game-lib-d3-geometry-normal-shape.js new file mode 100644 index 0000000..590ce21 --- /dev/null +++ b/src/game-lib-d3-geometry-normal-shape.js @@ -0,0 +1,112 @@ +/** + * GameLib.D3.Geometry.Normal.Shape + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalShape + * @constructor + */ +GameLib.D3.Geometry.Normal.Shape = function( + graphics, + apiGeometryNormalShape +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalShape)) { + apiGeometryNormalShape = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SHAPE + }; + } + + GameLib.D3.API.Geometry.Normal.Shape.call( + this, + apiGeometryNormalShape, + apiGeometryNormalShape.shapes, + apiGeometryNormalShape.curveSegments + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalShape + ); + +}; + +GameLib.D3.Geometry.Normal.Shape.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Shape.prototype.constructor = GameLib.D3.Geometry.Normal.Shape; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Shape.prototype.createInstance = function() { + + if (this.shapes.length === 0) { + console.warn('shapes are not ready for this instance'); + return; + } + + this.instance = new THREE.ShapeGeometry( + this.shapes.map( + function(shape) { + return shape.instance; + } + ), + this.curveSegments + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Shape.prototype.updateInstance = function(property) { + + if ( + property === 'shapes' || + property === 'curveSegments' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + console.warn('do other properties here'); + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Shape to a GameLib.D3.API.Geometry.Normal.Shape + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Shape.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalShape = new GameLib.D3.API.Geometry.Normal.Shape( + apiNormalGeometry, + this.shapes.map( + function(shape) { + return GameLib.Utils.IdOrNull(shape); + } + ), + this.curveSegments + ); + + return apiGeometryNormalShape; +}; diff --git a/src/game-lib-d3-geometry-normal-sphere.js b/src/game-lib-d3-geometry-normal-sphere.js new file mode 100644 index 0000000..c9b5e5c --- /dev/null +++ b/src/game-lib-d3-geometry-normal-sphere.js @@ -0,0 +1,117 @@ +/** + * GameLib.D3.Geometry.Normal.Sphere + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalSphere + * @constructor + */ +GameLib.D3.Geometry.Normal.Sphere = function( + graphics, + apiGeometryNormalSphere +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalSphere)) { + apiGeometryNormalSphere = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_SPHERE + }; + } + + GameLib.D3.API.Geometry.Normal.Sphere.call( + this, + apiGeometryNormalSphere, + apiGeometryNormalSphere.radius, + apiGeometryNormalSphere.widthSegments, + apiGeometryNormalSphere.heightSegments, + apiGeometryNormalSphere.phiStart, + apiGeometryNormalSphere.phiLength, + apiGeometryNormalSphere.thetaStart, + apiGeometryNormalSphere.thetaLength + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalSphere + ); + +}; + +GameLib.D3.Geometry.Normal.Sphere.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Sphere.prototype.constructor = GameLib.D3.Geometry.Normal.Sphere; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Sphere.prototype.createInstance = function() { + + this.instance = new THREE.SphereGeometry( + this.radius, + this.widthSegments, + this.heightSegments, + this.phiStart, + this.phiLength, + this.thetaStart, + this.thetaLength + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Sphere.prototype.updateInstance = function(property) { + + if ( + property === 'radius' || + property === 'widthSegments' || + property === 'heightSegments' || + property === 'phiStart' || + property === 'phiLength' || + property === 'thetaStart' || + property === 'thetaLength' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Sphere to a GameLib.D3.API.Geometry.Normal.Sphere + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Sphere.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalSphere = new GameLib.D3.API.Geometry.Normal.Sphere( + apiNormalGeometry, + this.radius, + this.widthSegments, + this.heightSegments, + this.phiStart, + this.phiLength, + this.thetaStart, + this.thetaLength + ); + + return apiGeometryNormalSphere; +}; diff --git a/src/game-lib-d3-geometry-normal-tetrahedron.js b/src/game-lib-d3-geometry-normal-tetrahedron.js new file mode 100644 index 0000000..52425d6 --- /dev/null +++ b/src/game-lib-d3-geometry-normal-tetrahedron.js @@ -0,0 +1,97 @@ +/** + * GameLib.D3.Geometry.Normal.Tetrahedron + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalTetrahedron + * @constructor + */ +GameLib.D3.Geometry.Normal.Tetrahedron = function( + graphics, + apiGeometryNormalTetrahedron +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalTetrahedron)) { + apiGeometryNormalTetrahedron = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TETRAHEDRON + }; + } + + GameLib.D3.API.Geometry.Normal.Tetrahedron.call( + this, + apiGeometryNormalTetrahedron, + apiGeometryNormalTetrahedron.radius, + apiGeometryNormalTetrahedron.detail + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalTetrahedron + ); + +}; + +GameLib.D3.Geometry.Normal.Tetrahedron.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Tetrahedron.prototype.constructor = GameLib.D3.Geometry.Normal.Tetrahedron; + +/** + * Create Instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Tetrahedron.prototype.createInstance = function() { + + this.instance = new THREE.TetrahedronGeometry( + this.radius, + this.detail + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Tetrahedron.prototype.updateInstance = function(property) { + + if ( + property === 'radius' || + property === 'detail' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Tetrahedron to a GameLib.D3.API.Geometry.Normal.Tetrahedron + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Tetrahedron.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalTetrahedron = new GameLib.D3.API.Geometry.Normal.Tetrahedron( + apiNormalGeometry, + this.radius, + this.detail + ); + + return apiGeometryNormalTetrahedron; +}; diff --git a/src/game-lib-d3-geometry-normal-text.js b/src/game-lib-d3-geometry-normal-text.js new file mode 100644 index 0000000..31b28e9 --- /dev/null +++ b/src/game-lib-d3-geometry-normal-text.js @@ -0,0 +1,141 @@ +/** + * GameLib.D3.Geometry.Normal.Text + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalText + * @constructor + */ +GameLib.D3.Geometry.Normal.Text = function( + graphics, + apiGeometryNormalText +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalText)) { + apiGeometryNormalText = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TEXT + }; + } + + GameLib.D3.API.Geometry.Normal.Text.call( + this, + apiGeometryNormalText, + apiGeometryNormalText.text, + apiGeometryNormalText.font, + apiGeometryNormalText.size, + apiGeometryNormalText.height, + apiGeometryNormalText.curveSegments, + apiGeometryNormalText.bevelEnabled, + apiGeometryNormalText.bevelThickness, + apiGeometryNormalText.bevelSize, + apiGeometryNormalText.bevelSegments + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalText + ); + +}; + +GameLib.D3.Geometry.Normal.Text.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Text.prototype.constructor = GameLib.D3.Geometry.Normal.Text; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Text.prototype.createInstance = function() { + + if (!this.font || !this.font.instance) { + console.warn('font not ready for this instance'); + return; + } + + this.instance = new THREE.TextGeometry( + this.text, + { + font : this.font.instance, + size : this.size, + curveSegments : this.curveSegments, + steps : this.steps, + amount : this.amount, + bevelEnabled : this.bevelEnabled, + bevelThickness : this.bevelThickness, + bevelSize : this.bevelSize, + bevelSegments : this.bevelSegments + } + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Text.prototype.updateInstance = function(property) { + + if ( + property === 'text' || + property === 'font' || + property === 'size' || + property === 'height' || + property === 'curveSegments' || + property === 'bevelEnabled' || + property === 'bevelThickness' || + property === 'bevelSize' || + property === 'bevelSegments' + ) { + /** + * Could be that the instance does not exist - because font was not ready + */ + if (this.instance) { + this.instance.dispose(); + } + + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + console.warn('do other properties here'); + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Text to a GameLib.D3.API.Geometry.Normal.Text + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Text.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalText = new GameLib.D3.API.Geometry.Normal.Text( + apiNormalGeometry, + this.text, + GameLib.Utils.IdOrNull(this.font), + this.size, + this.height, + this.curveSegments, + this.bevelEnabled, + this.bevelThickness, + this.bevelSize, + this.bevelSegments + ); + + return apiGeometryNormalText; +}; diff --git a/src/game-lib-d3-geometry-normal-torus-knot.js b/src/game-lib-d3-geometry-normal-torus-knot.js new file mode 100644 index 0000000..651bc97 --- /dev/null +++ b/src/game-lib-d3-geometry-normal-torus-knot.js @@ -0,0 +1,113 @@ +/** + * GameLib.D3.Geometry.Normal.TorusKnot + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalTorusKnot + * @constructor + */ +GameLib.D3.Geometry.Normal.TorusKnot = function( + graphics, + apiGeometryNormalTorusKnot +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalTorusKnot)) { + apiGeometryNormalTorusKnot = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TORUS_KNOT + }; + } + + GameLib.D3.API.Geometry.Normal.TorusKnot.call( + this, + apiGeometryNormalTorusKnot, + apiGeometryNormalTorusKnot.radius, + apiGeometryNormalTorusKnot.tube, + apiGeometryNormalTorusKnot.radialSegments, + apiGeometryNormalTorusKnot.tubularSegments, + apiGeometryNormalTorusKnot.p, + apiGeometryNormalTorusKnot.q + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalTorusKnot + ); + +}; + +GameLib.D3.Geometry.Normal.TorusKnot.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.TorusKnot.prototype.constructor = GameLib.D3.Geometry.Normal.TorusKnot; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.TorusKnot.prototype.createInstance = function() { + + this.instance = new THREE.TorusKnotGeometry( + this.radius, + this.tube, + this.radialSegments, + this.tubularSegments, + this.p, + this.q + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.TorusKnot.prototype.updateInstance = function(property) { + + if ( + property === 'radius' || + property === 'tube' || + property === 'radialSegments' || + property === 'tubularSegments' || + property === 'p' || + property === 'q' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.TorusKnot to a GameLib.D3.API.Geometry.Normal.TorusKnot + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.TorusKnot.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalTorusKnot = new GameLib.D3.API.Geometry.Normal.TorusKnot( + apiNormalGeometry, + this.radius, + this.tube, + this.radialSegments, + this.tubularSegments, + this.p, + this.q + ); + + return apiGeometryNormalTorusKnot; +}; diff --git a/src/game-lib-d3-geometry-normal-torus.js b/src/game-lib-d3-geometry-normal-torus.js new file mode 100644 index 0000000..8ef5595 --- /dev/null +++ b/src/game-lib-d3-geometry-normal-torus.js @@ -0,0 +1,109 @@ +/** + * GameLib.D3.Geometry.Normal.Torus + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalTorus + * @constructor + */ +GameLib.D3.Geometry.Normal.Torus = function( + graphics, + apiGeometryNormalTorus +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalTorus)) { + apiGeometryNormalTorus = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TORUS + }; + } + + GameLib.D3.API.Geometry.Normal.Torus.call( + this, + apiGeometryNormalTorus, + apiGeometryNormalTorus.radius, + apiGeometryNormalTorus.tube, + apiGeometryNormalTorus.radialSegments, + apiGeometryNormalTorus.tubularSegments, + apiGeometryNormalTorus.arc + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalTorus + ); + +}; + +GameLib.D3.Geometry.Normal.Torus.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Torus.prototype.constructor = GameLib.D3.Geometry.Normal.Torus; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Torus.prototype.createInstance = function() { + + this.instance = new THREE.TorusGeometry( + this.radius, + this.tube, + this.radialSegments, + this.tubularSegments, + this.arc + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Torus.prototype.updateInstance = function(property) { + + if ( + property === 'radius' || + property === 'tube' || + property === 'radialSegments' || + property === 'tubularSegments' || + property === 'arc' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Torus to a GameLib.D3.API.Geometry.Normal.Torus + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Torus.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalTorus = new GameLib.D3.API.Geometry.Normal.Torus( + apiNormalGeometry, + this.radius, + this.tube, + this.radialSegments, + this.tubularSegments, + this.arc + ); + + return apiGeometryNormalTorus; +}; diff --git a/src/game-lib-d3-geometry-normal-tube.js b/src/game-lib-d3-geometry-normal-tube.js new file mode 100644 index 0000000..b1a1465 --- /dev/null +++ b/src/game-lib-d3-geometry-normal-tube.js @@ -0,0 +1,109 @@ +/** + * GameLib.D3.Geometry.Normal.Tube + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalTube + * @constructor + */ +GameLib.D3.Geometry.Normal.Tube = function( + graphics, + apiGeometryNormalTube +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalTube)) { + apiGeometryNormalTube = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_TUBE + }; + } + + GameLib.D3.API.Geometry.Normal.Tube.call( + this, + apiGeometryNormalTube, + apiGeometryNormalTube.path, + apiGeometryNormalTube.tubularSegments, + apiGeometryNormalTube.radius, + apiGeometryNormalTube.radialSegments, + apiGeometryNormalTube.closed + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalTube + ); + +}; + +GameLib.D3.Geometry.Normal.Tube.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Tube.prototype.constructor = GameLib.D3.Geometry.Normal.Tube; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Tube.prototype.createInstance = function() { + + this.instance = new THREE.TubeGeometry( + this.path.instance, + this.tubularSegments, + this.radius, + this.radialSegments, + this.closed + ); + + this.computeVertexNormals(); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Tube.prototype.updateInstance = function(property) { + + if ( + property === 'path' || + property === 'tubularSegments' || + property === 'radius' || + property === 'radialSegments' || + property === 'closed' + ) { + this.instance.dispose(); + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Tube to a GameLib.D3.API.Geometry.Normal.Tube + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Tube.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalTube = new GameLib.D3.API.Geometry.Normal.Tube( + apiNormalGeometry, + GameLib.Utils.IdOrNull(this.path), + this.tubularSegments, + this.radius, + this.radialSegments, + this.closed + ); + + return apiGeometryNormalTube; +}; diff --git a/src/game-lib-d3-geometry-normal-wireframe.js b/src/game-lib-d3-geometry-normal-wireframe.js new file mode 100644 index 0000000..6f16a68 --- /dev/null +++ b/src/game-lib-d3-geometry-normal-wireframe.js @@ -0,0 +1,104 @@ +/** + * GameLib.D3.Geometry.Normal.Wireframe + * @param graphics GameLib.GraphicsRuntime + * @param apiGeometryNormalWireframe + * @constructor + */ +GameLib.D3.Geometry.Normal.Wireframe = function( + graphics, + apiGeometryNormalWireframe +) { + + this.graphics = graphics; + this.graphics.isNotThreeThrow(); + + if (GameLib.Utils.UndefinedOrNull(apiGeometryNormalWireframe)) { + apiGeometryNormalWireframe = { + geometryType : GameLib.D3.API.Geometry.GEOMETRY_TYPE_NORMAL_WIREFRAME + }; + } + + GameLib.D3.API.Geometry.Normal.Wireframe.call( + this, + apiGeometryNormalWireframe, + apiGeometryNormalWireframe.geometry + ); + + GameLib.D3.Geometry.Normal.call( + this, + this.graphics, + apiGeometryNormalWireframe + ); + +}; + +GameLib.D3.Geometry.Normal.Wireframe.prototype = Object.create(GameLib.D3.Geometry.Normal.prototype); +GameLib.D3.Geometry.Normal.Wireframe.prototype.constructor = GameLib.D3.Geometry.Normal.Wireframe; + +/** + * Creates a light instance + * @returns {*} + */ +GameLib.D3.Geometry.Normal.Wireframe.prototype.createInstance = function() { + + if (!this.geometry || !this.geometry.instance) { + console.warn('geometry not ready'); + return; + } + + this.instance = new THREE.WireframeGeometry( + this.geometry.instance + ); + + console.log('wireframe instance created'); + + GameLib.D3.Geometry.Normal.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +GameLib.D3.Geometry.Normal.Wireframe.prototype.updateInstance = function(property) { + + if ( + property === 'geometry' + ) { + /** + * Could be that geometry was not ready + */ + if (this.instance) { + this.instance.dispose(); + } + + this.createInstance(); + + if (this.parentMesh && this.parentMesh.instance) { + this.parentMesh.instance.geometry = this.instance; + + if (this.parentMesh.helper) { + this.parentMesh.removeHelper(); + this.parentMesh.createHelper(); + } + } + + return; + } + + GameLib.D3.Geometry.Normal.prototype.updateInstance.call(this, property); +}; + +/** + * Converts a GameLib.D3.Geometry.Normal.Wireframe to a GameLib.D3.API.Geometry.Normal.Wireframe + * @returns {GameLib.D3.API.Geometry.Normal} + */ +GameLib.D3.Geometry.Normal.Wireframe.prototype.toApiObject = function() { + + var apiNormalGeometry = GameLib.D3.Geometry.Normal.prototype.toApiObject.call(this); + + var apiGeometryNormalWireframe = new GameLib.D3.API.Geometry.Normal.Wireframe( + apiNormalGeometry, + GameLib.Utils.IdOrNull(this.geometry) + ); + + return apiGeometryNormalWireframe; +}; diff --git a/src/game-lib-d3-mesh-0.js b/src/game-lib-d3-mesh-0.js index b727fb4..a0ca038 100644 --- a/src/game-lib-d3-mesh-0.js +++ b/src/game-lib-d3-mesh-0.js @@ -105,7 +105,7 @@ GameLib.D3.Mesh = function ( 'parentMesh' : GameLib.D3.Mesh, 'parentScene' : GameLib.D3.Scene, 'materials' : [GameLib.D3.Material], - 'geometry' : GameLib.D3.BufferGeometry, + 'geometry' : GameLib.D3.Geometry, 'skeleton' : GameLib.D3.Skeleton }; @@ -149,6 +149,9 @@ GameLib.D3.Mesh.prototype.createInstance = function() { return; } + this.geometry.parentMesh = this; + this.geometry.updateInstance('parentMesh'); + var materialInstances = GameLib.Utils.GetArrayInstances(this.materials); if ( @@ -265,6 +268,9 @@ GameLib.D3.Mesh.prototype.updateInstance = function(property) { return; } + this.geometry.parentMesh = this; + this.geometry.updateInstance('parentMesh'); + if (GameLib.Utils.UndefinedOrNull(this.instance)) { this.createInstance(); } else { diff --git a/src/game-lib-draw-range.js b/src/game-lib-draw-range.js index d007857..f721328 100644 --- a/src/game-lib-draw-range.js +++ b/src/game-lib-draw-range.js @@ -23,6 +23,13 @@ GameLib.DrawRange = function ( } this.parentGeometry = parentGeometry; + /** + * Mongo doesn't store Infinity + */ + if (apiDrawRange.count === null) { + apiDrawRange.count = Infinity; + } + GameLib.API.DrawRange.call( this, apiDrawRange.id, diff --git a/src/game-lib-group.js b/src/game-lib-group.js index eecbed5..35a615f 100644 --- a/src/game-lib-group.js +++ b/src/game-lib-group.js @@ -33,7 +33,7 @@ GameLib.Group = function ( apiGroup.materialIndex ); - this.createInstance(); + GameLib.Component.call(this); }; GameLib.Group.prototype = Object.create(GameLib.Component.prototype); @@ -49,7 +49,9 @@ GameLib.Group.prototype.createInstance = function() { start : this.start, count : this.count, materialIndex : this.materialIndex - } + }; + + GameLib.Component.prototype.createInstance.call(this); }; @@ -62,14 +64,21 @@ GameLib.Group.prototype.updateInstance = function(property) { console.warn('update the geometry instead'); if (property === 'start') { + this.instance.start = this.start; + return; } if (property === 'count') { + this.instance.count = this.count; + return; } if (property === 'materialIndex') { + this.instance.materialIndex = this.materialIndex; + return; } + GameLib.Component.prototype.updateInstance.call(this, property); }; /** diff --git a/src/game-lib-sphere.js b/src/game-lib-sphere.js index bb31aa8..f3906a2 100644 --- a/src/game-lib-sphere.js +++ b/src/game-lib-sphere.js @@ -29,6 +29,12 @@ GameLib.Sphere = function ( apiSphere.radius ); + this.center = new GameLib.Vector3( + this.implementation, + this.center, + this + ); + this.createInstance(); }; diff --git a/src/game-lib-system-gui.js b/src/game-lib-system-gui.js index 2072432..dd2e224 100644 --- a/src/game-lib-system-gui.js +++ b/src/game-lib-system-gui.js @@ -638,7 +638,7 @@ GameLib.System.GUI.prototype.buildArrayManagerControl = function( add: function () { componentTemplate.affected.map(function (component) { - if (component[property].indexOf(activeSelection.component) === -1) { + //if (component[property].indexOf(activeSelection.component) === -1) { component[property].push(activeSelection.component); GameLib.Event.Emit( @@ -653,7 +653,7 @@ GameLib.System.GUI.prototype.buildArrayManagerControl = function( component.updateInstance(property, activeSelection.component); // addArrayItem(activeSelection.component, component[property].length - 1); - } + //} }); GameLib.Event.Emit( @@ -1653,6 +1653,10 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate, property === 'eyeSep' ) { controllers.push(folder.add(object, property, -2, 2, 0.0001)); + } else if ( + property === 'arc' + ) { + controllers.push(folder.add(object, property, 0, 200, 0.001)); } else { controllers.push(folder.add(object, property, -1000, 1000, 0.1)); } diff --git a/src/game-lib-system-render.js b/src/game-lib-system-render.js index 557acb8..96e8601 100644 --- a/src/game-lib-system-render.js +++ b/src/game-lib-system-render.js @@ -386,11 +386,13 @@ GameLib.System.Render.prototype.replaceComponent = function(data) { var index = mesh.materials.indexOf(data.current); - if (index !== -1) { + while (index !== -1) { + mesh.materials[index] = data.replacement; mesh.updateInstance('materials'); - } + index = mesh.materials.indexOf(data.current); + } } ); }