@awayjs/scene 0.13.264 → 0.13.266
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +100 -100
- package/README.md +61 -61
- package/bundle/awayjs-scene.umd.js +2 -2
- package/bundle/awayjs-scene.umd.js.map +1 -1
- package/copyVersionToIndex.js +23 -23
- package/dist/index.d.ts +76 -75
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -66
- package/dist/lib/Scene.d.ts +84 -84
- package/dist/lib/Scene.js +288 -288
- package/dist/lib/Settings.d.ts +16 -16
- package/dist/lib/Settings.js +60 -60
- package/dist/lib/adapters/IDisplayObjectAdapter.d.ts +13 -13
- package/dist/lib/adapters/IDisplayObjectAdapter.js +1 -1
- package/dist/lib/adapters/IFilter.d.ts +24 -24
- package/dist/lib/adapters/IFilter.js +1 -1
- package/dist/lib/adapters/IMovieClipAdapter.d.ts +14 -14
- package/dist/lib/adapters/IMovieClipAdapter.js +1 -1
- package/dist/lib/adapters/ITextfieldAdapter.d.ts +4 -4
- package/dist/lib/adapters/ITextfieldAdapter.js +1 -1
- package/dist/lib/base/IBitmapDrawable.d.ts +11 -11
- package/dist/lib/base/IBitmapDrawable.js +1 -1
- package/dist/lib/base/IFrameLabel.d.ts +4 -4
- package/dist/lib/base/IFrameLabel.js +1 -1
- package/dist/lib/base/IFrameScript.d.ts +5 -5
- package/dist/lib/base/IFrameScript.js +1 -1
- package/dist/lib/base/MouseButtons.d.ts +26 -22
- package/dist/lib/base/MouseButtons.d.ts.map +1 -1
- package/dist/lib/base/MouseButtons.js +1 -1
- package/dist/lib/base/Timeline.d.ts +148 -148
- package/dist/lib/base/Timeline.js +535 -535
- package/dist/lib/base/TimelineActionType.d.ts +18 -18
- package/dist/lib/base/TimelineActionType.js +1 -1
- package/dist/lib/controllers/ControllerBase.d.ts +14 -14
- package/dist/lib/controllers/ControllerBase.js +60 -60
- package/dist/lib/controllers/FirstPersonController.d.ts +78 -78
- package/dist/lib/controllers/FirstPersonController.js +228 -228
- package/dist/lib/controllers/FollowController.d.ts +12 -12
- package/dist/lib/controllers/FollowController.js +27 -27
- package/dist/lib/controllers/HoverController.d.ts +105 -105
- package/dist/lib/controllers/HoverController.js +302 -302
- package/dist/lib/controllers/LookAtController.d.ts +14 -14
- package/dist/lib/controllers/LookAtController.js +68 -68
- package/dist/lib/controllers/SpringController.d.ts +38 -38
- package/dist/lib/controllers/SpringController.js +59 -59
- package/dist/lib/display/Billboard.d.ts +147 -147
- package/dist/lib/display/Billboard.js +426 -426
- package/dist/lib/display/Camera.d.ts +40 -40
- package/dist/lib/display/Camera.js +90 -90
- package/dist/lib/display/DisplayObject.d.ts +938 -938
- package/dist/lib/display/DisplayObject.js +1641 -1641
- package/dist/lib/display/DisplayObjectContainer.d.ts +325 -325
- package/dist/lib/display/DisplayObjectContainer.js +480 -480
- package/dist/lib/display/LineSegment.d.ts +84 -84
- package/dist/lib/display/LineSegment.js +215 -215
- package/dist/lib/display/LoaderContainer.d.ts +504 -504
- package/dist/lib/display/LoaderContainer.js +603 -603
- package/dist/lib/display/MorphSprite.d.ts +20 -20
- package/dist/lib/display/MorphSprite.js +254 -254
- package/dist/lib/display/MovieClip.d.ts +152 -152
- package/dist/lib/display/MovieClip.js +735 -735
- package/dist/lib/display/SimpleButton.d.ts +158 -158
- package/dist/lib/display/SimpleButton.js +228 -228
- package/dist/lib/display/Skybox.d.ts +156 -156
- package/dist/lib/display/Skybox.js +309 -309
- package/dist/lib/display/Sprite.d.ts +70 -70
- package/dist/lib/display/Sprite.js +144 -144
- package/dist/lib/display/TextField.d.ts +1109 -1109
- package/dist/lib/display/TextField.js +3109 -3109
- package/dist/lib/display/TextSprite.d.ts +10 -10
- package/dist/lib/display/TextSprite.js +25 -25
- package/dist/lib/elements/SkyboxElements.d.ts +29 -29
- package/dist/lib/elements/SkyboxElements.js +127 -127
- package/dist/lib/errors/CastError.d.ts +4 -4
- package/dist/lib/errors/CastError.js +10 -10
- package/dist/lib/events/CameraEvent.d.ts +16 -16
- package/dist/lib/events/CameraEvent.js +30 -30
- package/dist/lib/events/FocusEvent.d.ts +42 -42
- package/dist/lib/events/FocusEvent.js +43 -43
- package/dist/lib/events/KeyboardEvent.d.ts +21 -21
- package/dist/lib/events/KeyboardEvent.js +43 -43
- package/dist/lib/events/MouseEvent.d.ts +91 -184
- package/dist/lib/events/MouseEvent.d.ts.map +1 -1
- package/dist/lib/events/MouseEvent.js +122 -191
- package/dist/lib/events/PointerEvent.d.ts +94 -0
- package/dist/lib/events/PointerEvent.d.ts.map +1 -0
- package/dist/lib/events/PointerEvent.js +73 -0
- package/dist/lib/events/ResizeEvent.d.ts +15 -15
- package/dist/lib/events/ResizeEvent.js +38 -38
- package/dist/lib/events/TextfieldEvent.d.ts +19 -19
- package/dist/lib/events/TextfieldEvent.js +28 -28
- package/dist/lib/events/TouchEvent.d.ts +51 -0
- package/dist/lib/events/TouchEvent.d.ts.map +1 -0
- package/dist/lib/events/TouchEvent.js +83 -0
- package/dist/lib/factories/DefaultSceneGraphFactory.d.ts +26 -26
- package/dist/lib/factories/DefaultSceneGraphFactory.js +54 -54
- package/dist/lib/factories/ISceneGraphFactory.d.ts +20 -20
- package/dist/lib/factories/ISceneGraphFactory.js +1 -1
- package/dist/lib/image/SceneImage2D.d.ts +236 -236
- package/dist/lib/image/SceneImage2D.js +687 -687
- package/dist/lib/managers/DefaultFontManager.d.ts +14 -14
- package/dist/lib/managers/DefaultFontManager.js +101 -101
- package/dist/lib/managers/DeviceFontManager.d.ts +8 -8
- package/dist/lib/managers/DeviceFontManager.js +44 -44
- package/dist/lib/managers/FrameScriptManager.d.ts +36 -36
- package/dist/lib/managers/FrameScriptManager.js +377 -377
- package/dist/lib/managers/IInputRecorder.d.ts +3 -3
- package/dist/lib/managers/IInputRecorder.js +1 -1
- package/dist/lib/managers/MouseManager.d.ts +76 -89
- package/dist/lib/managers/MouseManager.d.ts.map +1 -1
- package/dist/lib/managers/MouseManager.js +809 -759
- package/dist/lib/prefabs/PrefabBase.d.ts +19 -19
- package/dist/lib/prefabs/PrefabBase.js +42 -42
- package/dist/lib/prefabs/PrimitiveCapsulePrefab.d.ts +56 -56
- package/dist/lib/prefabs/PrimitiveCapsulePrefab.js +269 -269
- package/dist/lib/prefabs/PrimitiveConePrefab.d.ts +21 -21
- package/dist/lib/prefabs/PrimitiveConePrefab.js +43 -43
- package/dist/lib/prefabs/PrimitiveCubePrefab.d.ts +74 -74
- package/dist/lib/prefabs/PrimitiveCubePrefab.js +545 -545
- package/dist/lib/prefabs/PrimitiveCylinderPrefab.d.ts +79 -79
- package/dist/lib/prefabs/PrimitiveCylinderPrefab.js +584 -584
- package/dist/lib/prefabs/PrimitivePlanePrefab.d.ts +65 -65
- package/dist/lib/prefabs/PrimitivePlanePrefab.js +300 -300
- package/dist/lib/prefabs/PrimitivePolygonPrefab.d.ts +29 -29
- package/dist/lib/prefabs/PrimitivePolygonPrefab.js +64 -64
- package/dist/lib/prefabs/PrimitivePrefabBase.d.ts +67 -67
- package/dist/lib/prefabs/PrimitivePrefabBase.js +158 -158
- package/dist/lib/prefabs/PrimitiveSpherePrefab.d.ts +48 -48
- package/dist/lib/prefabs/PrimitiveSpherePrefab.js +294 -294
- package/dist/lib/prefabs/PrimitiveTorusPrefab.d.ts +55 -55
- package/dist/lib/prefabs/PrimitiveTorusPrefab.js +260 -260
- package/dist/lib/text/AntiAliasType.d.ts +24 -24
- package/dist/lib/text/AntiAliasType.js +28 -28
- package/dist/lib/text/BitmapFontChar.d.ts +39 -39
- package/dist/lib/text/BitmapFontChar.js +42 -42
- package/dist/lib/text/BitmapFontTable.d.ts +80 -80
- package/dist/lib/text/BitmapFontTable.js +203 -203
- package/dist/lib/text/FNTGenerator.d.ts +10 -10
- package/dist/lib/text/FNTGenerator.js +74 -74
- package/dist/lib/text/FNTGeneratorCanvas.d.ts +22 -22
- package/dist/lib/text/FNTGeneratorCanvas.js +205 -205
- package/dist/lib/text/FNTGeneratrorBase.d.ts +7 -7
- package/dist/lib/text/FNTGeneratrorBase.js +7 -7
- package/dist/lib/text/Font.d.ts +38 -38
- package/dist/lib/text/Font.js +109 -109
- package/dist/lib/text/FontLookUpMode.d.ts +5 -5
- package/dist/lib/text/FontLookUpMode.js +7 -7
- package/dist/lib/text/FontStyleName.d.ts +6 -6
- package/dist/lib/text/FontStyleName.js +7 -7
- package/dist/lib/text/GridFitType.d.ts +31 -31
- package/dist/lib/text/GridFitType.js +35 -35
- package/dist/lib/text/HTMLTextProcessor.d.ts +8 -8
- package/dist/lib/text/HTMLTextProcessor.js +423 -423
- package/dist/lib/text/IFontTable.d.ts +16 -16
- package/dist/lib/text/IFontTable.js +1 -1
- package/dist/lib/text/TesselatedFontChar.d.ts +58 -58
- package/dist/lib/text/TesselatedFontChar.js +66 -66
- package/dist/lib/text/TesselatedFontTable.d.ts +95 -95
- package/dist/lib/text/TesselatedFontTable.js +992 -992
- package/dist/lib/text/TextFieldAutoSize.d.ts +28 -28
- package/dist/lib/text/TextFieldAutoSize.js +32 -32
- package/dist/lib/text/TextFieldType.d.ts +20 -20
- package/dist/lib/text/TextFieldType.js +24 -24
- package/dist/lib/text/TextFormat.d.ts +273 -273
- package/dist/lib/text/TextFormat.js +440 -440
- package/dist/lib/text/TextFormatAlign.d.ts +26 -26
- package/dist/lib/text/TextFormatAlign.js +30 -30
- package/dist/lib/text/TextInteractionMode.d.ts +21 -21
- package/dist/lib/text/TextInteractionMode.js +25 -25
- package/dist/lib/text/TextLineMetrics.d.ts +61 -61
- package/dist/lib/text/TextLineMetrics.js +42 -42
- package/dist/lib/text/TextShape.d.ts +20 -20
- package/dist/lib/text/TextShape.js +75 -75
- package/dist/lib/tools/Merge.d.ts +81 -81
- package/dist/lib/tools/Merge.js +266 -266
- package/dist/lib/utils/Cast.d.ts +20 -20
- package/dist/lib/utils/Cast.js +271 -271
- package/index.ts +92 -91
- package/lib/Scene.ts +343 -343
- package/lib/Settings.ts +83 -83
- package/lib/adapters/IDisplayObjectAdapter.ts +23 -23
- package/lib/adapters/IFilter.ts +25 -25
- package/lib/adapters/IMovieClipAdapter.ts +24 -24
- package/lib/adapters/ITextfieldAdapter.ts +6 -6
- package/lib/base/IBitmapDrawable.ts +13 -13
- package/lib/base/IFrameLabel.ts +3 -3
- package/lib/base/IFrameScript.ts +4 -4
- package/lib/base/MouseButtons.ts +31 -26
- package/lib/base/Timeline.ts +727 -727
- package/lib/base/TimelineActionType.ts +18 -18
- package/lib/controllers/ControllerBase.ts +66 -66
- package/lib/controllers/FirstPersonController.ts +241 -241
- package/lib/controllers/FollowController.ts +22 -22
- package/lib/controllers/HoverController.ts +304 -304
- package/lib/controllers/LookAtController.ts +75 -75
- package/lib/controllers/SpringController.ts +91 -91
- package/lib/display/Billboard.ts +504 -504
- package/lib/display/Camera.ts +89 -89
- package/lib/display/DisplayObject.ts +1893 -1893
- package/lib/display/DisplayObjectContainer.ts +538 -538
- package/lib/display/LineSegment.ts +248 -248
- package/lib/display/LoaderContainer.ts +651 -651
- package/lib/display/MorphSprite.ts +347 -347
- package/lib/display/MovieClip.ts +879 -879
- package/lib/display/SimpleButton.ts +224 -224
- package/lib/display/Skybox.ts +379 -379
- package/lib/display/Sprite.ts +165 -165
- package/lib/display/TextField.ts +3958 -3958
- package/lib/display/TextSprite.ts +22 -22
- package/lib/elements/SkyboxElements.ts +141 -141
- package/lib/errors/CastError.ts +6 -6
- package/lib/events/CameraEvent.ts +29 -29
- package/lib/events/FocusEvent.ts +69 -69
- package/lib/events/KeyboardEvent.ts +40 -40
- package/lib/events/MouseEvent.ts +147 -287
- package/lib/events/PointerEvent.ts +146 -0
- package/lib/events/ResizeEvent.ts +31 -31
- package/lib/events/TextfieldEvent.ts +28 -28
- package/lib/events/TouchEvent.ts +101 -0
- package/lib/factories/DefaultSceneGraphFactory.ts +56 -56
- package/lib/factories/ISceneGraphFactory.ts +28 -28
- package/lib/image/SceneImage2D.ts +1020 -1020
- package/lib/managers/DefaultFontManager.ts +124 -124
- package/lib/managers/DeviceFontManager.ts +55 -55
- package/lib/managers/FrameScriptManager.ts +431 -431
- package/lib/managers/IInputRecorder.ts +2 -2
- package/lib/managers/MouseManager.ts +944 -882
- package/lib/prefabs/PrefabBase.ts +47 -47
- package/lib/prefabs/PrimitiveCapsulePrefab.ts +286 -286
- package/lib/prefabs/PrimitiveConePrefab.ts +37 -37
- package/lib/prefabs/PrimitiveCubePrefab.ts +630 -630
- package/lib/prefabs/PrimitiveCylinderPrefab.ts +657 -657
- package/lib/prefabs/PrimitivePlanePrefab.ts +352 -352
- package/lib/prefabs/PrimitivePolygonPrefab.ts +53 -53
- package/lib/prefabs/PrimitivePrefabBase.ts +177 -177
- package/lib/prefabs/PrimitiveSpherePrefab.ts +336 -336
- package/lib/prefabs/PrimitiveTorusPrefab.ts +282 -282
- package/lib/text/AntiAliasType.ts +24 -24
- package/lib/text/BitmapFontChar.ts +53 -53
- package/lib/text/BitmapFontTable.ts +232 -232
- package/lib/text/FNTGenerator.ts +100 -100
- package/lib/text/FNTGeneratorCanvas.ts +287 -287
- package/lib/text/FNTGeneratrorBase.ts +10 -10
- package/lib/text/Font.ts +114 -114
- package/lib/text/FontLookUpMode.ts +5 -5
- package/lib/text/FontStyleName.ts +6 -6
- package/lib/text/GridFitType.ts +32 -32
- package/lib/text/HTMLTextProcessor.ts +418 -418
- package/lib/text/IFontTable.ts +17 -17
- package/lib/text/TesselatedFontChar.ts +80 -80
- package/lib/text/TesselatedFontTable.ts +1221 -1221
- package/lib/text/TextFieldAutoSize.ts +30 -30
- package/lib/text/TextFieldType.ts +21 -21
- package/lib/text/TextFormat.ts +601 -601
- package/lib/text/TextFormatAlign.ts +28 -28
- package/lib/text/TextInteractionMode.ts +21 -21
- package/lib/text/TextLineMetrics.ts +74 -74
- package/lib/text/TextShape.ts +90 -90
- package/lib/tools/Merge.ts +311 -311
- package/lib/utils/Cast.ts +304 -304
- package/package.json +74 -74
- package/rollup.config.js +33 -33
- package/scripts/build.sh +2 -2
- package/scripts/gendocs.sh +14 -14
- package/scripts/genexamples.sh +14 -14
- package/scripts/genfull.sh +14 -14
- package/system.config.js +51 -51
- package/tsconfig.json +18 -18
|
@@ -1,545 +1,545 @@
|
|
|
1
|
-
import { __extends } from "tslib";
|
|
2
|
-
import { ElementsType } from '@awayjs/renderer';
|
|
3
|
-
import { PrimitivePrefabBase } from '../prefabs/PrimitivePrefabBase';
|
|
4
|
-
/**
|
|
5
|
-
* A Cube primitive prefab.
|
|
6
|
-
*/
|
|
7
|
-
var PrimitiveCubePrefab = /** @class */ (function (_super) {
|
|
8
|
-
__extends(PrimitiveCubePrefab, _super);
|
|
9
|
-
/**
|
|
10
|
-
* Creates a new Cube object.
|
|
11
|
-
* @param width The size of the cube along its X-axis.
|
|
12
|
-
* @param height The size of the cube along its Y-axis.
|
|
13
|
-
* @param depth The size of the cube along its Z-axis.
|
|
14
|
-
* @param segmentsW The number of segments that make up the cube along the X-axis.
|
|
15
|
-
* @param segmentsH The number of segments that make up the cube along the Y-axis.
|
|
16
|
-
* @param segmentsD The number of segments that make up the cube along the Z-axis.
|
|
17
|
-
* @param tile6 The type of uv mapping to use. When true, a texture will be subdivided in a 2x3 grid,
|
|
18
|
-
* each used for a single face. When false, the entire image is mapped on each face.
|
|
19
|
-
*/
|
|
20
|
-
function PrimitiveCubePrefab(material, elementsType, width, height, depth, segmentsW, segmentsH, segmentsD, tile6) {
|
|
21
|
-
if (material === void 0) { material = null; }
|
|
22
|
-
if (elementsType === void 0) { elementsType = 'triangle'; }
|
|
23
|
-
if (width === void 0) { width = 100; }
|
|
24
|
-
if (height === void 0) { height = 100; }
|
|
25
|
-
if (depth === void 0) { depth = 100; }
|
|
26
|
-
if (segmentsW === void 0) { segmentsW = 1; }
|
|
27
|
-
if (segmentsH === void 0) { segmentsH = 1; }
|
|
28
|
-
if (segmentsD === void 0) { segmentsD = 1; }
|
|
29
|
-
if (tile6 === void 0) { tile6 = true; }
|
|
30
|
-
var _this = _super.call(this, material, elementsType) || this;
|
|
31
|
-
_this._width = width;
|
|
32
|
-
_this._height = height;
|
|
33
|
-
_this._depth = depth;
|
|
34
|
-
_this._segmentsW = segmentsW;
|
|
35
|
-
_this._segmentsH = segmentsH;
|
|
36
|
-
_this._segmentsD = segmentsD;
|
|
37
|
-
_this._tile6 = tile6;
|
|
38
|
-
return _this;
|
|
39
|
-
}
|
|
40
|
-
Object.defineProperty(PrimitiveCubePrefab.prototype, "width", {
|
|
41
|
-
/**
|
|
42
|
-
* The size of the cube along its X-axis.
|
|
43
|
-
*/
|
|
44
|
-
get: function () {
|
|
45
|
-
return this._width;
|
|
46
|
-
},
|
|
47
|
-
set: function (value) {
|
|
48
|
-
this._width = value;
|
|
49
|
-
this._pInvalidatePrimitive();
|
|
50
|
-
},
|
|
51
|
-
enumerable: false,
|
|
52
|
-
configurable: true
|
|
53
|
-
});
|
|
54
|
-
Object.defineProperty(PrimitiveCubePrefab.prototype, "height", {
|
|
55
|
-
/**
|
|
56
|
-
* The size of the cube along its Y-axis.
|
|
57
|
-
*/
|
|
58
|
-
get: function () {
|
|
59
|
-
return this._height;
|
|
60
|
-
},
|
|
61
|
-
set: function (value) {
|
|
62
|
-
this._height = value;
|
|
63
|
-
this._pInvalidatePrimitive();
|
|
64
|
-
},
|
|
65
|
-
enumerable: false,
|
|
66
|
-
configurable: true
|
|
67
|
-
});
|
|
68
|
-
Object.defineProperty(PrimitiveCubePrefab.prototype, "depth", {
|
|
69
|
-
/**
|
|
70
|
-
* The size of the cube along its Z-axis.
|
|
71
|
-
*/
|
|
72
|
-
get: function () {
|
|
73
|
-
return this._depth;
|
|
74
|
-
},
|
|
75
|
-
set: function (value) {
|
|
76
|
-
this._depth = value;
|
|
77
|
-
this._pInvalidatePrimitive();
|
|
78
|
-
},
|
|
79
|
-
enumerable: false,
|
|
80
|
-
configurable: true
|
|
81
|
-
});
|
|
82
|
-
Object.defineProperty(PrimitiveCubePrefab.prototype, "tile6", {
|
|
83
|
-
/**
|
|
84
|
-
* The type of uv mapping to use. When false, the entire image is mapped on each face.
|
|
85
|
-
* When true, a texture will be subdivided in a 3x2 grid, each used for a single face.
|
|
86
|
-
* Reading the tiles from left to right, top to bottom they represent the faces of the
|
|
87
|
-
* cube in the following order: bottom, top, back, left, front, right. This creates
|
|
88
|
-
* several shared edges (between the top, front, left and right faces) which simplifies
|
|
89
|
-
* texture painting.
|
|
90
|
-
*/
|
|
91
|
-
get: function () {
|
|
92
|
-
return this._tile6;
|
|
93
|
-
},
|
|
94
|
-
set: function (value) {
|
|
95
|
-
this._tile6 = value;
|
|
96
|
-
this._pInvalidatePrimitive();
|
|
97
|
-
},
|
|
98
|
-
enumerable: false,
|
|
99
|
-
configurable: true
|
|
100
|
-
});
|
|
101
|
-
Object.defineProperty(PrimitiveCubePrefab.prototype, "segmentsW", {
|
|
102
|
-
/**
|
|
103
|
-
* The number of segments that make up the cube along the X-axis. Defaults to 1.
|
|
104
|
-
*/
|
|
105
|
-
get: function () {
|
|
106
|
-
return this._segmentsW;
|
|
107
|
-
},
|
|
108
|
-
set: function (value) {
|
|
109
|
-
this._segmentsW = value;
|
|
110
|
-
this._pInvalidatePrimitive();
|
|
111
|
-
this._pInvalidateUVs();
|
|
112
|
-
},
|
|
113
|
-
enumerable: false,
|
|
114
|
-
configurable: true
|
|
115
|
-
});
|
|
116
|
-
Object.defineProperty(PrimitiveCubePrefab.prototype, "segmentsH", {
|
|
117
|
-
/**
|
|
118
|
-
* The number of segments that make up the cube along the Y-axis. Defaults to 1.
|
|
119
|
-
*/
|
|
120
|
-
get: function () {
|
|
121
|
-
return this._segmentsH;
|
|
122
|
-
},
|
|
123
|
-
set: function (value) {
|
|
124
|
-
this._segmentsH = value;
|
|
125
|
-
this._pInvalidatePrimitive();
|
|
126
|
-
this._pInvalidateUVs();
|
|
127
|
-
},
|
|
128
|
-
enumerable: false,
|
|
129
|
-
configurable: true
|
|
130
|
-
});
|
|
131
|
-
Object.defineProperty(PrimitiveCubePrefab.prototype, "segmentsD", {
|
|
132
|
-
/**
|
|
133
|
-
* The number of segments that make up the cube along the Z-axis. Defaults to 1.
|
|
134
|
-
*/
|
|
135
|
-
get: function () {
|
|
136
|
-
return this._segmentsD;
|
|
137
|
-
},
|
|
138
|
-
set: function (value) {
|
|
139
|
-
this._segmentsD = value;
|
|
140
|
-
this._pInvalidatePrimitive();
|
|
141
|
-
this._pInvalidateUVs();
|
|
142
|
-
},
|
|
143
|
-
enumerable: false,
|
|
144
|
-
configurable: true
|
|
145
|
-
});
|
|
146
|
-
/**
|
|
147
|
-
* @inheritDoc
|
|
148
|
-
*/
|
|
149
|
-
PrimitiveCubePrefab.prototype._pBuildGraphics = function (target, elementsType) {
|
|
150
|
-
var indices;
|
|
151
|
-
var positions;
|
|
152
|
-
var normals;
|
|
153
|
-
var tangents;
|
|
154
|
-
var stride;
|
|
155
|
-
var tl, tr, bl, br;
|
|
156
|
-
var i, j, inc = 0;
|
|
157
|
-
var vidx, fidx; // indices
|
|
158
|
-
var dw, dh, dd; // deltas
|
|
159
|
-
var outer_pos;
|
|
160
|
-
// half cube dimensions
|
|
161
|
-
var hw = this._width / 2;
|
|
162
|
-
var hh = this._height / 2;
|
|
163
|
-
var hd = this._depth / 2;
|
|
164
|
-
if (elementsType == ElementsType.TRIANGLE) {
|
|
165
|
-
var triangleGraphics = target;
|
|
166
|
-
var numVertices = ((this._segmentsW + 1) * (this._segmentsH + 1) +
|
|
167
|
-
(this._segmentsW + 1) * (this._segmentsD + 1) + (this._segmentsH + 1) * (this._segmentsD + 1)) * 2;
|
|
168
|
-
var numIndices = ((this._segmentsW * this._segmentsH +
|
|
169
|
-
this._segmentsW * this._segmentsD + this._segmentsH * this._segmentsD) * 12);
|
|
170
|
-
if (numVertices == triangleGraphics.numVertices && triangleGraphics.indices != null) {
|
|
171
|
-
triangleGraphics.invalidateIndices();
|
|
172
|
-
triangleGraphics.invalidateVertices(triangleGraphics.positions);
|
|
173
|
-
triangleGraphics.invalidateVertices(triangleGraphics.normals);
|
|
174
|
-
triangleGraphics.invalidateVertices(triangleGraphics.tangents);
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
triangleGraphics.setIndices(new Uint16Array(numIndices));
|
|
178
|
-
triangleGraphics.setPositions(new Float32Array(numVertices * 3));
|
|
179
|
-
triangleGraphics.setNormals(new Float32Array(numVertices * 3));
|
|
180
|
-
triangleGraphics.setTangents(new Float32Array(numVertices * 3));
|
|
181
|
-
this._pInvalidateUVs();
|
|
182
|
-
}
|
|
183
|
-
indices = triangleGraphics.indices.get(triangleGraphics.numElements);
|
|
184
|
-
positions = triangleGraphics.positions.get(numVertices);
|
|
185
|
-
normals = triangleGraphics.normals.get(numVertices);
|
|
186
|
-
tangents = triangleGraphics.tangents.get(numVertices);
|
|
187
|
-
stride = triangleGraphics.concatenatedBuffer.stride / 4;
|
|
188
|
-
vidx = 0;
|
|
189
|
-
fidx = 0;
|
|
190
|
-
// Segment dimensions
|
|
191
|
-
dw = this._width / this._segmentsW;
|
|
192
|
-
dh = this._height / this._segmentsH;
|
|
193
|
-
dd = this._depth / this._segmentsD;
|
|
194
|
-
for (i = 0; i <= this._segmentsW; i++) {
|
|
195
|
-
outer_pos = -hw + i * dw;
|
|
196
|
-
for (j = 0; j <= this._segmentsH; j++) {
|
|
197
|
-
// front
|
|
198
|
-
positions[vidx] = outer_pos;
|
|
199
|
-
positions[vidx + 1] = -hh + j * dh;
|
|
200
|
-
positions[vidx + 2] = -hd;
|
|
201
|
-
normals[vidx] = 0;
|
|
202
|
-
normals[vidx + 1] = 0;
|
|
203
|
-
normals[vidx + 2] = -1;
|
|
204
|
-
tangents[vidx] = 1;
|
|
205
|
-
tangents[vidx + 1] = 0;
|
|
206
|
-
tangents[vidx + 2] = 0;
|
|
207
|
-
vidx += stride;
|
|
208
|
-
// back
|
|
209
|
-
positions[vidx] = outer_pos;
|
|
210
|
-
positions[vidx + 1] = -hh + j * dh;
|
|
211
|
-
positions[vidx + 2] = hd;
|
|
212
|
-
normals[vidx] = 0;
|
|
213
|
-
normals[vidx + 1] = 0;
|
|
214
|
-
normals[vidx + 2] = 1;
|
|
215
|
-
tangents[vidx] = -1;
|
|
216
|
-
tangents[vidx + 1] = 0;
|
|
217
|
-
tangents[vidx + 2] = 0;
|
|
218
|
-
vidx += stride;
|
|
219
|
-
if (i && j) {
|
|
220
|
-
tl = 2 * ((i - 1) * (this._segmentsH + 1) + (j - 1));
|
|
221
|
-
tr = 2 * (i * (this._segmentsH + 1) + (j - 1));
|
|
222
|
-
bl = tl + 2;
|
|
223
|
-
br = tr + 2;
|
|
224
|
-
indices[fidx++] = tl;
|
|
225
|
-
indices[fidx++] = bl;
|
|
226
|
-
indices[fidx++] = br;
|
|
227
|
-
indices[fidx++] = tl;
|
|
228
|
-
indices[fidx++] = br;
|
|
229
|
-
indices[fidx++] = tr;
|
|
230
|
-
indices[fidx++] = tr + 1;
|
|
231
|
-
indices[fidx++] = br + 1;
|
|
232
|
-
indices[fidx++] = bl + 1;
|
|
233
|
-
indices[fidx++] = tr + 1;
|
|
234
|
-
indices[fidx++] = bl + 1;
|
|
235
|
-
indices[fidx++] = tl + 1;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
inc += 2 * (this._segmentsW + 1) * (this._segmentsH + 1);
|
|
240
|
-
for (i = 0; i <= this._segmentsW; i++) {
|
|
241
|
-
outer_pos = -hw + i * dw;
|
|
242
|
-
for (j = 0; j <= this._segmentsD; j++) {
|
|
243
|
-
// top
|
|
244
|
-
positions[vidx] = outer_pos;
|
|
245
|
-
positions[vidx + 1] = hh;
|
|
246
|
-
positions[vidx + 2] = -hd + j * dd;
|
|
247
|
-
normals[vidx] = 0;
|
|
248
|
-
normals[vidx + 1] = 1;
|
|
249
|
-
normals[vidx + 2] = 0;
|
|
250
|
-
tangents[vidx] = 1;
|
|
251
|
-
tangents[vidx + 1] = 0;
|
|
252
|
-
tangents[vidx + 2] = 0;
|
|
253
|
-
vidx += stride;
|
|
254
|
-
// bottom
|
|
255
|
-
positions[vidx] = outer_pos;
|
|
256
|
-
positions[vidx + 1] = -hh;
|
|
257
|
-
positions[vidx + 2] = -hd + j * dd;
|
|
258
|
-
normals[vidx] = 0;
|
|
259
|
-
normals[vidx + 1] = -1;
|
|
260
|
-
normals[vidx + 2] = 0;
|
|
261
|
-
tangents[vidx] = 1;
|
|
262
|
-
tangents[vidx + 1] = 0;
|
|
263
|
-
tangents[vidx + 2] = 0;
|
|
264
|
-
vidx += stride;
|
|
265
|
-
if (i && j) {
|
|
266
|
-
tl = inc + 2 * ((i - 1) * (this._segmentsD + 1) + (j - 1));
|
|
267
|
-
tr = inc + 2 * (i * (this._segmentsD + 1) + (j - 1));
|
|
268
|
-
bl = tl + 2;
|
|
269
|
-
br = tr + 2;
|
|
270
|
-
indices[fidx++] = tl;
|
|
271
|
-
indices[fidx++] = bl;
|
|
272
|
-
indices[fidx++] = br;
|
|
273
|
-
indices[fidx++] = tl;
|
|
274
|
-
indices[fidx++] = br;
|
|
275
|
-
indices[fidx++] = tr;
|
|
276
|
-
indices[fidx++] = tr + 1;
|
|
277
|
-
indices[fidx++] = br + 1;
|
|
278
|
-
indices[fidx++] = bl + 1;
|
|
279
|
-
indices[fidx++] = tr + 1;
|
|
280
|
-
indices[fidx++] = bl + 1;
|
|
281
|
-
indices[fidx++] = tl + 1;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
inc += 2 * (this._segmentsW + 1) * (this._segmentsD + 1);
|
|
286
|
-
for (i = 0; i <= this._segmentsD; i++) {
|
|
287
|
-
outer_pos = hd - i * dd;
|
|
288
|
-
for (j = 0; j <= this._segmentsH; j++) {
|
|
289
|
-
// left
|
|
290
|
-
positions[vidx] = -hw;
|
|
291
|
-
positions[vidx + 1] = -hh + j * dh;
|
|
292
|
-
positions[vidx + 2] = outer_pos;
|
|
293
|
-
normals[vidx] = -1;
|
|
294
|
-
normals[vidx + 1] = 0;
|
|
295
|
-
normals[vidx + 2] = 0;
|
|
296
|
-
tangents[vidx] = 0;
|
|
297
|
-
tangents[vidx + 1] = 0;
|
|
298
|
-
tangents[vidx + 2] = -1;
|
|
299
|
-
vidx += stride;
|
|
300
|
-
// right
|
|
301
|
-
positions[vidx] = hw;
|
|
302
|
-
positions[vidx + 1] = -hh + j * dh;
|
|
303
|
-
positions[vidx + 2] = outer_pos;
|
|
304
|
-
normals[vidx] = 1;
|
|
305
|
-
normals[vidx + 1] = 0;
|
|
306
|
-
normals[vidx + 2] = 0;
|
|
307
|
-
tangents[vidx] = 0;
|
|
308
|
-
tangents[vidx + 1] = 0;
|
|
309
|
-
tangents[vidx + 2] = 1;
|
|
310
|
-
vidx += stride;
|
|
311
|
-
if (i && j) {
|
|
312
|
-
tl = inc + 2 * ((i - 1) * (this._segmentsH + 1) + (j - 1));
|
|
313
|
-
tr = inc + 2 * (i * (this._segmentsH + 1) + (j - 1));
|
|
314
|
-
bl = tl + 2;
|
|
315
|
-
br = tr + 2;
|
|
316
|
-
indices[fidx++] = tl;
|
|
317
|
-
indices[fidx++] = bl;
|
|
318
|
-
indices[fidx++] = br;
|
|
319
|
-
indices[fidx++] = tl;
|
|
320
|
-
indices[fidx++] = br;
|
|
321
|
-
indices[fidx++] = tr;
|
|
322
|
-
indices[fidx++] = tr + 1;
|
|
323
|
-
indices[fidx++] = br + 1;
|
|
324
|
-
indices[fidx++] = bl + 1;
|
|
325
|
-
indices[fidx++] = tr + 1;
|
|
326
|
-
indices[fidx++] = bl + 1;
|
|
327
|
-
indices[fidx++] = tl + 1;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
else if (elementsType == ElementsType.LINE) {
|
|
333
|
-
var lineGraphics = target;
|
|
334
|
-
var numSegments = this._segmentsH * 4 + this._segmentsW * 4 + this._segmentsD * 4;
|
|
335
|
-
positions = new Float32Array(numSegments * 6);
|
|
336
|
-
var thickness = new Float32Array(numSegments);
|
|
337
|
-
vidx = 0;
|
|
338
|
-
fidx = 0;
|
|
339
|
-
//front/back face
|
|
340
|
-
for (i = 0; i < this._segmentsH; ++i) {
|
|
341
|
-
positions[vidx++] = -hw;
|
|
342
|
-
positions[vidx++] = i * this._height / this._segmentsH - hh;
|
|
343
|
-
positions[vidx++] = -hd;
|
|
344
|
-
positions[vidx++] = hw;
|
|
345
|
-
positions[vidx++] = i * this._height / this._segmentsH - hh;
|
|
346
|
-
positions[vidx++] = -hd;
|
|
347
|
-
thickness[fidx++] = 1;
|
|
348
|
-
positions[vidx++] = -hw;
|
|
349
|
-
positions[vidx++] = hh - i * this._height / this._segmentsH;
|
|
350
|
-
positions[vidx++] = hd;
|
|
351
|
-
positions[vidx++] = hw;
|
|
352
|
-
positions[vidx++] = hh - i * this._height / this._segmentsH;
|
|
353
|
-
positions[vidx++] = hd;
|
|
354
|
-
thickness[fidx++] = 1;
|
|
355
|
-
}
|
|
356
|
-
for (i = 0; i < this._segmentsW; ++i) {
|
|
357
|
-
positions[vidx++] = i * this._width / this._segmentsW - hw;
|
|
358
|
-
positions[vidx++] = -hh;
|
|
359
|
-
positions[vidx++] = -hd;
|
|
360
|
-
positions[vidx++] = i * this._width / this._segmentsW - hw;
|
|
361
|
-
positions[vidx++] = hh;
|
|
362
|
-
positions[vidx++] = -hd;
|
|
363
|
-
thickness[fidx++] = 1;
|
|
364
|
-
positions[vidx++] = hw - i * this._width / this._segmentsW;
|
|
365
|
-
positions[vidx++] = -hh;
|
|
366
|
-
positions[vidx++] = hd;
|
|
367
|
-
positions[vidx++] = hw - i * this._width / this._segmentsW;
|
|
368
|
-
positions[vidx++] = hh;
|
|
369
|
-
positions[vidx++] = hd;
|
|
370
|
-
thickness[fidx++] = 1;
|
|
371
|
-
}
|
|
372
|
-
//left/right face
|
|
373
|
-
for (i = 0; i < this._segmentsH; ++i) {
|
|
374
|
-
positions[vidx++] = -hw;
|
|
375
|
-
positions[vidx++] = i * this._height / this._segmentsH - hh;
|
|
376
|
-
positions[vidx++] = -hd;
|
|
377
|
-
positions[vidx++] = -hw;
|
|
378
|
-
positions[vidx++] = i * this._height / this._segmentsH - hh;
|
|
379
|
-
positions[vidx++] = hd;
|
|
380
|
-
thickness[fidx++] = 1;
|
|
381
|
-
positions[vidx++] = hw;
|
|
382
|
-
positions[vidx++] = hh - i * this._height / this._segmentsH;
|
|
383
|
-
positions[vidx++] = -hd;
|
|
384
|
-
positions[vidx++] = hw;
|
|
385
|
-
positions[vidx++] = hh - i * this._height / this._segmentsH;
|
|
386
|
-
positions[vidx++] = hd;
|
|
387
|
-
thickness[fidx++] = 1;
|
|
388
|
-
}
|
|
389
|
-
for (i = 0; i < this._segmentsD; ++i) {
|
|
390
|
-
positions[vidx++] = hw;
|
|
391
|
-
positions[vidx++] = -hh;
|
|
392
|
-
positions[vidx++] = i * this._depth / this._segmentsD - hd;
|
|
393
|
-
positions[vidx++] = hw;
|
|
394
|
-
positions[vidx++] = hh;
|
|
395
|
-
positions[vidx++] = i * this._depth / this._segmentsD - hd;
|
|
396
|
-
thickness[fidx++] = 1;
|
|
397
|
-
positions[vidx++] = -hw;
|
|
398
|
-
positions[vidx++] = -hh;
|
|
399
|
-
positions[vidx++] = hd - i * this._depth / this._segmentsD;
|
|
400
|
-
positions[vidx++] = -hw;
|
|
401
|
-
positions[vidx++] = hh;
|
|
402
|
-
positions[vidx++] = hd - i * this._depth / this._segmentsD;
|
|
403
|
-
thickness[fidx++] = 1;
|
|
404
|
-
}
|
|
405
|
-
//top/bottom face
|
|
406
|
-
for (i = 0; i < this._segmentsD; ++i) {
|
|
407
|
-
positions[vidx++] = -hw;
|
|
408
|
-
positions[vidx++] = -hh;
|
|
409
|
-
positions[vidx++] = hd - i * this._depth / this._segmentsD;
|
|
410
|
-
positions[vidx++] = hw;
|
|
411
|
-
positions[vidx++] = -hh;
|
|
412
|
-
positions[vidx++] = hd - i * this._depth / this._segmentsD;
|
|
413
|
-
thickness[fidx++] = 1;
|
|
414
|
-
positions[vidx++] = -hw;
|
|
415
|
-
positions[vidx++] = hh;
|
|
416
|
-
positions[vidx++] = i * this._depth / this._segmentsD - hd;
|
|
417
|
-
positions[vidx++] = hw;
|
|
418
|
-
positions[vidx++] = hh;
|
|
419
|
-
positions[vidx++] = i * this._depth / this._segmentsD - hd;
|
|
420
|
-
thickness[fidx++] = 1;
|
|
421
|
-
}
|
|
422
|
-
for (i = 0; i < this._segmentsW; ++i) {
|
|
423
|
-
positions[vidx++] = hw - i * this._width / this._segmentsW;
|
|
424
|
-
positions[vidx++] = -hh;
|
|
425
|
-
positions[vidx++] = -hd;
|
|
426
|
-
positions[vidx++] = hw - i * this._width / this._segmentsW;
|
|
427
|
-
positions[vidx++] = -hh;
|
|
428
|
-
positions[vidx++] = hd;
|
|
429
|
-
thickness[fidx++] = 1;
|
|
430
|
-
positions[vidx++] = i * this._width / this._segmentsW - hw;
|
|
431
|
-
positions[vidx++] = hh;
|
|
432
|
-
positions[vidx++] = -hd;
|
|
433
|
-
positions[vidx++] = i * this._width / this._segmentsW - hw;
|
|
434
|
-
positions[vidx++] = hh;
|
|
435
|
-
positions[vidx++] = hd;
|
|
436
|
-
thickness[fidx++] = 1;
|
|
437
|
-
}
|
|
438
|
-
// build real data from raw data
|
|
439
|
-
lineGraphics.setPositions(positions);
|
|
440
|
-
lineGraphics.setThickness(thickness);
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
/**
|
|
444
|
-
* @inheritDoc
|
|
445
|
-
*/
|
|
446
|
-
PrimitiveCubePrefab.prototype._pBuildUVs = function (target, elementsType) {
|
|
447
|
-
var i, j, index;
|
|
448
|
-
var uvs;
|
|
449
|
-
var stride;
|
|
450
|
-
var u_tile_dim, v_tile_dim;
|
|
451
|
-
var u_tile_step, v_tile_step;
|
|
452
|
-
var tl0u, tl0v;
|
|
453
|
-
var tl1u, tl1v;
|
|
454
|
-
var du, dv;
|
|
455
|
-
var numVertices;
|
|
456
|
-
if (elementsType == ElementsType.TRIANGLE) {
|
|
457
|
-
numVertices = ((this._segmentsW + 1) * (this._segmentsH + 1) +
|
|
458
|
-
(this._segmentsW + 1) * (this._segmentsD + 1) + (this._segmentsH + 1) * (this._segmentsD + 1)) * 2;
|
|
459
|
-
var triangleGraphics = target;
|
|
460
|
-
if (triangleGraphics.uvs && numVertices == triangleGraphics.numVertices) {
|
|
461
|
-
triangleGraphics.invalidateVertices(triangleGraphics.uvs);
|
|
462
|
-
}
|
|
463
|
-
else {
|
|
464
|
-
triangleGraphics.setUVs(new Float32Array(numVertices * 2));
|
|
465
|
-
}
|
|
466
|
-
uvs = triangleGraphics.uvs.get(numVertices);
|
|
467
|
-
stride = triangleGraphics.uvs.stride;
|
|
468
|
-
if (this._tile6) {
|
|
469
|
-
u_tile_dim = u_tile_step = 1 / 3;
|
|
470
|
-
v_tile_dim = v_tile_step = 1 / 2;
|
|
471
|
-
}
|
|
472
|
-
else {
|
|
473
|
-
u_tile_dim = v_tile_dim = 1;
|
|
474
|
-
u_tile_step = v_tile_step = 0;
|
|
475
|
-
}
|
|
476
|
-
// Create planes two and two, the same way that they were
|
|
477
|
-
// constructed in the buildGraphics() function. First calculate
|
|
478
|
-
// the top-left UV coordinate for both planes, and then loop
|
|
479
|
-
// over the points, calculating the UVs from these numbers.
|
|
480
|
-
// When tile6 is true, the layout is as follows:
|
|
481
|
-
// .-----.-----.-----. (1,1)
|
|
482
|
-
// | Bot | T | Bak |
|
|
483
|
-
// |-----+-----+-----|
|
|
484
|
-
// | L | F | R |
|
|
485
|
-
// (0,0)'-----'-----'-----'
|
|
486
|
-
index = 0;
|
|
487
|
-
// FRONT / BACK
|
|
488
|
-
tl0u = 1 * u_tile_step;
|
|
489
|
-
tl0v = 1 * v_tile_step;
|
|
490
|
-
tl1u = 2 * u_tile_step;
|
|
491
|
-
tl1v = 0 * v_tile_step;
|
|
492
|
-
du = u_tile_dim / this._segmentsW;
|
|
493
|
-
dv = v_tile_dim / this._segmentsH;
|
|
494
|
-
for (i = 0; i <= this._segmentsW; i++) {
|
|
495
|
-
for (j = 0; j <= this._segmentsH; j++) {
|
|
496
|
-
uvs[index] = (tl0u + i * du) * this._scaleU;
|
|
497
|
-
uvs[index + 1] = (tl0v + (v_tile_dim - j * dv)) * this._scaleV;
|
|
498
|
-
index += stride;
|
|
499
|
-
uvs[index] = (tl1u + (u_tile_dim - i * du)) * this._scaleU;
|
|
500
|
-
uvs[index + 1] = (tl1v + (v_tile_dim - j * dv)) * this._scaleV;
|
|
501
|
-
index += stride;
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
// TOP / BOTTOM
|
|
505
|
-
tl0u = 1 * u_tile_step;
|
|
506
|
-
tl0v = 0 * v_tile_step;
|
|
507
|
-
tl1u = 0 * u_tile_step;
|
|
508
|
-
tl1v = 0 * v_tile_step;
|
|
509
|
-
du = u_tile_dim / this._segmentsW;
|
|
510
|
-
dv = v_tile_dim / this._segmentsD;
|
|
511
|
-
for (i = 0; i <= this._segmentsW; i++) {
|
|
512
|
-
for (j = 0; j <= this._segmentsD; j++) {
|
|
513
|
-
uvs[index] = (tl0u + i * du) * this._scaleU;
|
|
514
|
-
uvs[index + 1] = (tl0v + (v_tile_dim - j * dv)) * this._scaleV;
|
|
515
|
-
index += stride;
|
|
516
|
-
uvs[index] = (tl1u + i * du) * this._scaleU;
|
|
517
|
-
uvs[index + 1] = (tl1v + j * dv) * this._scaleV;
|
|
518
|
-
index += stride;
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
// LEFT / RIGHT
|
|
522
|
-
tl0u = 0 * u_tile_step;
|
|
523
|
-
tl0v = 1 * v_tile_step;
|
|
524
|
-
tl1u = 2 * u_tile_step;
|
|
525
|
-
tl1v = 1 * v_tile_step;
|
|
526
|
-
du = u_tile_dim / this._segmentsD;
|
|
527
|
-
dv = v_tile_dim / this._segmentsH;
|
|
528
|
-
for (i = 0; i <= this._segmentsD; i++) {
|
|
529
|
-
for (j = 0; j <= this._segmentsH; j++) {
|
|
530
|
-
uvs[index] = (tl0u + i * du) * this._scaleU;
|
|
531
|
-
uvs[index + 1] = (tl0v + (v_tile_dim - j * dv)) * this._scaleV;
|
|
532
|
-
index += stride;
|
|
533
|
-
uvs[index] = (tl1u + (u_tile_dim - i * du)) * this._scaleU;
|
|
534
|
-
uvs[index + 1] = (tl1v + (v_tile_dim - j * dv)) * this._scaleV;
|
|
535
|
-
index += stride;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
else if (elementsType == ElementsType.LINE) {
|
|
540
|
-
//nothing to do here
|
|
541
|
-
}
|
|
542
|
-
};
|
|
543
|
-
return PrimitiveCubePrefab;
|
|
544
|
-
}(PrimitivePrefabBase));
|
|
545
|
-
export { PrimitiveCubePrefab };
|
|
1
|
+
import { __extends } from "tslib";
|
|
2
|
+
import { ElementsType } from '@awayjs/renderer';
|
|
3
|
+
import { PrimitivePrefabBase } from '../prefabs/PrimitivePrefabBase';
|
|
4
|
+
/**
|
|
5
|
+
* A Cube primitive prefab.
|
|
6
|
+
*/
|
|
7
|
+
var PrimitiveCubePrefab = /** @class */ (function (_super) {
|
|
8
|
+
__extends(PrimitiveCubePrefab, _super);
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new Cube object.
|
|
11
|
+
* @param width The size of the cube along its X-axis.
|
|
12
|
+
* @param height The size of the cube along its Y-axis.
|
|
13
|
+
* @param depth The size of the cube along its Z-axis.
|
|
14
|
+
* @param segmentsW The number of segments that make up the cube along the X-axis.
|
|
15
|
+
* @param segmentsH The number of segments that make up the cube along the Y-axis.
|
|
16
|
+
* @param segmentsD The number of segments that make up the cube along the Z-axis.
|
|
17
|
+
* @param tile6 The type of uv mapping to use. When true, a texture will be subdivided in a 2x3 grid,
|
|
18
|
+
* each used for a single face. When false, the entire image is mapped on each face.
|
|
19
|
+
*/
|
|
20
|
+
function PrimitiveCubePrefab(material, elementsType, width, height, depth, segmentsW, segmentsH, segmentsD, tile6) {
|
|
21
|
+
if (material === void 0) { material = null; }
|
|
22
|
+
if (elementsType === void 0) { elementsType = 'triangle'; }
|
|
23
|
+
if (width === void 0) { width = 100; }
|
|
24
|
+
if (height === void 0) { height = 100; }
|
|
25
|
+
if (depth === void 0) { depth = 100; }
|
|
26
|
+
if (segmentsW === void 0) { segmentsW = 1; }
|
|
27
|
+
if (segmentsH === void 0) { segmentsH = 1; }
|
|
28
|
+
if (segmentsD === void 0) { segmentsD = 1; }
|
|
29
|
+
if (tile6 === void 0) { tile6 = true; }
|
|
30
|
+
var _this = _super.call(this, material, elementsType) || this;
|
|
31
|
+
_this._width = width;
|
|
32
|
+
_this._height = height;
|
|
33
|
+
_this._depth = depth;
|
|
34
|
+
_this._segmentsW = segmentsW;
|
|
35
|
+
_this._segmentsH = segmentsH;
|
|
36
|
+
_this._segmentsD = segmentsD;
|
|
37
|
+
_this._tile6 = tile6;
|
|
38
|
+
return _this;
|
|
39
|
+
}
|
|
40
|
+
Object.defineProperty(PrimitiveCubePrefab.prototype, "width", {
|
|
41
|
+
/**
|
|
42
|
+
* The size of the cube along its X-axis.
|
|
43
|
+
*/
|
|
44
|
+
get: function () {
|
|
45
|
+
return this._width;
|
|
46
|
+
},
|
|
47
|
+
set: function (value) {
|
|
48
|
+
this._width = value;
|
|
49
|
+
this._pInvalidatePrimitive();
|
|
50
|
+
},
|
|
51
|
+
enumerable: false,
|
|
52
|
+
configurable: true
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(PrimitiveCubePrefab.prototype, "height", {
|
|
55
|
+
/**
|
|
56
|
+
* The size of the cube along its Y-axis.
|
|
57
|
+
*/
|
|
58
|
+
get: function () {
|
|
59
|
+
return this._height;
|
|
60
|
+
},
|
|
61
|
+
set: function (value) {
|
|
62
|
+
this._height = value;
|
|
63
|
+
this._pInvalidatePrimitive();
|
|
64
|
+
},
|
|
65
|
+
enumerable: false,
|
|
66
|
+
configurable: true
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(PrimitiveCubePrefab.prototype, "depth", {
|
|
69
|
+
/**
|
|
70
|
+
* The size of the cube along its Z-axis.
|
|
71
|
+
*/
|
|
72
|
+
get: function () {
|
|
73
|
+
return this._depth;
|
|
74
|
+
},
|
|
75
|
+
set: function (value) {
|
|
76
|
+
this._depth = value;
|
|
77
|
+
this._pInvalidatePrimitive();
|
|
78
|
+
},
|
|
79
|
+
enumerable: false,
|
|
80
|
+
configurable: true
|
|
81
|
+
});
|
|
82
|
+
Object.defineProperty(PrimitiveCubePrefab.prototype, "tile6", {
|
|
83
|
+
/**
|
|
84
|
+
* The type of uv mapping to use. When false, the entire image is mapped on each face.
|
|
85
|
+
* When true, a texture will be subdivided in a 3x2 grid, each used for a single face.
|
|
86
|
+
* Reading the tiles from left to right, top to bottom they represent the faces of the
|
|
87
|
+
* cube in the following order: bottom, top, back, left, front, right. This creates
|
|
88
|
+
* several shared edges (between the top, front, left and right faces) which simplifies
|
|
89
|
+
* texture painting.
|
|
90
|
+
*/
|
|
91
|
+
get: function () {
|
|
92
|
+
return this._tile6;
|
|
93
|
+
},
|
|
94
|
+
set: function (value) {
|
|
95
|
+
this._tile6 = value;
|
|
96
|
+
this._pInvalidatePrimitive();
|
|
97
|
+
},
|
|
98
|
+
enumerable: false,
|
|
99
|
+
configurable: true
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(PrimitiveCubePrefab.prototype, "segmentsW", {
|
|
102
|
+
/**
|
|
103
|
+
* The number of segments that make up the cube along the X-axis. Defaults to 1.
|
|
104
|
+
*/
|
|
105
|
+
get: function () {
|
|
106
|
+
return this._segmentsW;
|
|
107
|
+
},
|
|
108
|
+
set: function (value) {
|
|
109
|
+
this._segmentsW = value;
|
|
110
|
+
this._pInvalidatePrimitive();
|
|
111
|
+
this._pInvalidateUVs();
|
|
112
|
+
},
|
|
113
|
+
enumerable: false,
|
|
114
|
+
configurable: true
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(PrimitiveCubePrefab.prototype, "segmentsH", {
|
|
117
|
+
/**
|
|
118
|
+
* The number of segments that make up the cube along the Y-axis. Defaults to 1.
|
|
119
|
+
*/
|
|
120
|
+
get: function () {
|
|
121
|
+
return this._segmentsH;
|
|
122
|
+
},
|
|
123
|
+
set: function (value) {
|
|
124
|
+
this._segmentsH = value;
|
|
125
|
+
this._pInvalidatePrimitive();
|
|
126
|
+
this._pInvalidateUVs();
|
|
127
|
+
},
|
|
128
|
+
enumerable: false,
|
|
129
|
+
configurable: true
|
|
130
|
+
});
|
|
131
|
+
Object.defineProperty(PrimitiveCubePrefab.prototype, "segmentsD", {
|
|
132
|
+
/**
|
|
133
|
+
* The number of segments that make up the cube along the Z-axis. Defaults to 1.
|
|
134
|
+
*/
|
|
135
|
+
get: function () {
|
|
136
|
+
return this._segmentsD;
|
|
137
|
+
},
|
|
138
|
+
set: function (value) {
|
|
139
|
+
this._segmentsD = value;
|
|
140
|
+
this._pInvalidatePrimitive();
|
|
141
|
+
this._pInvalidateUVs();
|
|
142
|
+
},
|
|
143
|
+
enumerable: false,
|
|
144
|
+
configurable: true
|
|
145
|
+
});
|
|
146
|
+
/**
|
|
147
|
+
* @inheritDoc
|
|
148
|
+
*/
|
|
149
|
+
PrimitiveCubePrefab.prototype._pBuildGraphics = function (target, elementsType) {
|
|
150
|
+
var indices;
|
|
151
|
+
var positions;
|
|
152
|
+
var normals;
|
|
153
|
+
var tangents;
|
|
154
|
+
var stride;
|
|
155
|
+
var tl, tr, bl, br;
|
|
156
|
+
var i, j, inc = 0;
|
|
157
|
+
var vidx, fidx; // indices
|
|
158
|
+
var dw, dh, dd; // deltas
|
|
159
|
+
var outer_pos;
|
|
160
|
+
// half cube dimensions
|
|
161
|
+
var hw = this._width / 2;
|
|
162
|
+
var hh = this._height / 2;
|
|
163
|
+
var hd = this._depth / 2;
|
|
164
|
+
if (elementsType == ElementsType.TRIANGLE) {
|
|
165
|
+
var triangleGraphics = target;
|
|
166
|
+
var numVertices = ((this._segmentsW + 1) * (this._segmentsH + 1) +
|
|
167
|
+
(this._segmentsW + 1) * (this._segmentsD + 1) + (this._segmentsH + 1) * (this._segmentsD + 1)) * 2;
|
|
168
|
+
var numIndices = ((this._segmentsW * this._segmentsH +
|
|
169
|
+
this._segmentsW * this._segmentsD + this._segmentsH * this._segmentsD) * 12);
|
|
170
|
+
if (numVertices == triangleGraphics.numVertices && triangleGraphics.indices != null) {
|
|
171
|
+
triangleGraphics.invalidateIndices();
|
|
172
|
+
triangleGraphics.invalidateVertices(triangleGraphics.positions);
|
|
173
|
+
triangleGraphics.invalidateVertices(triangleGraphics.normals);
|
|
174
|
+
triangleGraphics.invalidateVertices(triangleGraphics.tangents);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
triangleGraphics.setIndices(new Uint16Array(numIndices));
|
|
178
|
+
triangleGraphics.setPositions(new Float32Array(numVertices * 3));
|
|
179
|
+
triangleGraphics.setNormals(new Float32Array(numVertices * 3));
|
|
180
|
+
triangleGraphics.setTangents(new Float32Array(numVertices * 3));
|
|
181
|
+
this._pInvalidateUVs();
|
|
182
|
+
}
|
|
183
|
+
indices = triangleGraphics.indices.get(triangleGraphics.numElements);
|
|
184
|
+
positions = triangleGraphics.positions.get(numVertices);
|
|
185
|
+
normals = triangleGraphics.normals.get(numVertices);
|
|
186
|
+
tangents = triangleGraphics.tangents.get(numVertices);
|
|
187
|
+
stride = triangleGraphics.concatenatedBuffer.stride / 4;
|
|
188
|
+
vidx = 0;
|
|
189
|
+
fidx = 0;
|
|
190
|
+
// Segment dimensions
|
|
191
|
+
dw = this._width / this._segmentsW;
|
|
192
|
+
dh = this._height / this._segmentsH;
|
|
193
|
+
dd = this._depth / this._segmentsD;
|
|
194
|
+
for (i = 0; i <= this._segmentsW; i++) {
|
|
195
|
+
outer_pos = -hw + i * dw;
|
|
196
|
+
for (j = 0; j <= this._segmentsH; j++) {
|
|
197
|
+
// front
|
|
198
|
+
positions[vidx] = outer_pos;
|
|
199
|
+
positions[vidx + 1] = -hh + j * dh;
|
|
200
|
+
positions[vidx + 2] = -hd;
|
|
201
|
+
normals[vidx] = 0;
|
|
202
|
+
normals[vidx + 1] = 0;
|
|
203
|
+
normals[vidx + 2] = -1;
|
|
204
|
+
tangents[vidx] = 1;
|
|
205
|
+
tangents[vidx + 1] = 0;
|
|
206
|
+
tangents[vidx + 2] = 0;
|
|
207
|
+
vidx += stride;
|
|
208
|
+
// back
|
|
209
|
+
positions[vidx] = outer_pos;
|
|
210
|
+
positions[vidx + 1] = -hh + j * dh;
|
|
211
|
+
positions[vidx + 2] = hd;
|
|
212
|
+
normals[vidx] = 0;
|
|
213
|
+
normals[vidx + 1] = 0;
|
|
214
|
+
normals[vidx + 2] = 1;
|
|
215
|
+
tangents[vidx] = -1;
|
|
216
|
+
tangents[vidx + 1] = 0;
|
|
217
|
+
tangents[vidx + 2] = 0;
|
|
218
|
+
vidx += stride;
|
|
219
|
+
if (i && j) {
|
|
220
|
+
tl = 2 * ((i - 1) * (this._segmentsH + 1) + (j - 1));
|
|
221
|
+
tr = 2 * (i * (this._segmentsH + 1) + (j - 1));
|
|
222
|
+
bl = tl + 2;
|
|
223
|
+
br = tr + 2;
|
|
224
|
+
indices[fidx++] = tl;
|
|
225
|
+
indices[fidx++] = bl;
|
|
226
|
+
indices[fidx++] = br;
|
|
227
|
+
indices[fidx++] = tl;
|
|
228
|
+
indices[fidx++] = br;
|
|
229
|
+
indices[fidx++] = tr;
|
|
230
|
+
indices[fidx++] = tr + 1;
|
|
231
|
+
indices[fidx++] = br + 1;
|
|
232
|
+
indices[fidx++] = bl + 1;
|
|
233
|
+
indices[fidx++] = tr + 1;
|
|
234
|
+
indices[fidx++] = bl + 1;
|
|
235
|
+
indices[fidx++] = tl + 1;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
inc += 2 * (this._segmentsW + 1) * (this._segmentsH + 1);
|
|
240
|
+
for (i = 0; i <= this._segmentsW; i++) {
|
|
241
|
+
outer_pos = -hw + i * dw;
|
|
242
|
+
for (j = 0; j <= this._segmentsD; j++) {
|
|
243
|
+
// top
|
|
244
|
+
positions[vidx] = outer_pos;
|
|
245
|
+
positions[vidx + 1] = hh;
|
|
246
|
+
positions[vidx + 2] = -hd + j * dd;
|
|
247
|
+
normals[vidx] = 0;
|
|
248
|
+
normals[vidx + 1] = 1;
|
|
249
|
+
normals[vidx + 2] = 0;
|
|
250
|
+
tangents[vidx] = 1;
|
|
251
|
+
tangents[vidx + 1] = 0;
|
|
252
|
+
tangents[vidx + 2] = 0;
|
|
253
|
+
vidx += stride;
|
|
254
|
+
// bottom
|
|
255
|
+
positions[vidx] = outer_pos;
|
|
256
|
+
positions[vidx + 1] = -hh;
|
|
257
|
+
positions[vidx + 2] = -hd + j * dd;
|
|
258
|
+
normals[vidx] = 0;
|
|
259
|
+
normals[vidx + 1] = -1;
|
|
260
|
+
normals[vidx + 2] = 0;
|
|
261
|
+
tangents[vidx] = 1;
|
|
262
|
+
tangents[vidx + 1] = 0;
|
|
263
|
+
tangents[vidx + 2] = 0;
|
|
264
|
+
vidx += stride;
|
|
265
|
+
if (i && j) {
|
|
266
|
+
tl = inc + 2 * ((i - 1) * (this._segmentsD + 1) + (j - 1));
|
|
267
|
+
tr = inc + 2 * (i * (this._segmentsD + 1) + (j - 1));
|
|
268
|
+
bl = tl + 2;
|
|
269
|
+
br = tr + 2;
|
|
270
|
+
indices[fidx++] = tl;
|
|
271
|
+
indices[fidx++] = bl;
|
|
272
|
+
indices[fidx++] = br;
|
|
273
|
+
indices[fidx++] = tl;
|
|
274
|
+
indices[fidx++] = br;
|
|
275
|
+
indices[fidx++] = tr;
|
|
276
|
+
indices[fidx++] = tr + 1;
|
|
277
|
+
indices[fidx++] = br + 1;
|
|
278
|
+
indices[fidx++] = bl + 1;
|
|
279
|
+
indices[fidx++] = tr + 1;
|
|
280
|
+
indices[fidx++] = bl + 1;
|
|
281
|
+
indices[fidx++] = tl + 1;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
inc += 2 * (this._segmentsW + 1) * (this._segmentsD + 1);
|
|
286
|
+
for (i = 0; i <= this._segmentsD; i++) {
|
|
287
|
+
outer_pos = hd - i * dd;
|
|
288
|
+
for (j = 0; j <= this._segmentsH; j++) {
|
|
289
|
+
// left
|
|
290
|
+
positions[vidx] = -hw;
|
|
291
|
+
positions[vidx + 1] = -hh + j * dh;
|
|
292
|
+
positions[vidx + 2] = outer_pos;
|
|
293
|
+
normals[vidx] = -1;
|
|
294
|
+
normals[vidx + 1] = 0;
|
|
295
|
+
normals[vidx + 2] = 0;
|
|
296
|
+
tangents[vidx] = 0;
|
|
297
|
+
tangents[vidx + 1] = 0;
|
|
298
|
+
tangents[vidx + 2] = -1;
|
|
299
|
+
vidx += stride;
|
|
300
|
+
// right
|
|
301
|
+
positions[vidx] = hw;
|
|
302
|
+
positions[vidx + 1] = -hh + j * dh;
|
|
303
|
+
positions[vidx + 2] = outer_pos;
|
|
304
|
+
normals[vidx] = 1;
|
|
305
|
+
normals[vidx + 1] = 0;
|
|
306
|
+
normals[vidx + 2] = 0;
|
|
307
|
+
tangents[vidx] = 0;
|
|
308
|
+
tangents[vidx + 1] = 0;
|
|
309
|
+
tangents[vidx + 2] = 1;
|
|
310
|
+
vidx += stride;
|
|
311
|
+
if (i && j) {
|
|
312
|
+
tl = inc + 2 * ((i - 1) * (this._segmentsH + 1) + (j - 1));
|
|
313
|
+
tr = inc + 2 * (i * (this._segmentsH + 1) + (j - 1));
|
|
314
|
+
bl = tl + 2;
|
|
315
|
+
br = tr + 2;
|
|
316
|
+
indices[fidx++] = tl;
|
|
317
|
+
indices[fidx++] = bl;
|
|
318
|
+
indices[fidx++] = br;
|
|
319
|
+
indices[fidx++] = tl;
|
|
320
|
+
indices[fidx++] = br;
|
|
321
|
+
indices[fidx++] = tr;
|
|
322
|
+
indices[fidx++] = tr + 1;
|
|
323
|
+
indices[fidx++] = br + 1;
|
|
324
|
+
indices[fidx++] = bl + 1;
|
|
325
|
+
indices[fidx++] = tr + 1;
|
|
326
|
+
indices[fidx++] = bl + 1;
|
|
327
|
+
indices[fidx++] = tl + 1;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
else if (elementsType == ElementsType.LINE) {
|
|
333
|
+
var lineGraphics = target;
|
|
334
|
+
var numSegments = this._segmentsH * 4 + this._segmentsW * 4 + this._segmentsD * 4;
|
|
335
|
+
positions = new Float32Array(numSegments * 6);
|
|
336
|
+
var thickness = new Float32Array(numSegments);
|
|
337
|
+
vidx = 0;
|
|
338
|
+
fidx = 0;
|
|
339
|
+
//front/back face
|
|
340
|
+
for (i = 0; i < this._segmentsH; ++i) {
|
|
341
|
+
positions[vidx++] = -hw;
|
|
342
|
+
positions[vidx++] = i * this._height / this._segmentsH - hh;
|
|
343
|
+
positions[vidx++] = -hd;
|
|
344
|
+
positions[vidx++] = hw;
|
|
345
|
+
positions[vidx++] = i * this._height / this._segmentsH - hh;
|
|
346
|
+
positions[vidx++] = -hd;
|
|
347
|
+
thickness[fidx++] = 1;
|
|
348
|
+
positions[vidx++] = -hw;
|
|
349
|
+
positions[vidx++] = hh - i * this._height / this._segmentsH;
|
|
350
|
+
positions[vidx++] = hd;
|
|
351
|
+
positions[vidx++] = hw;
|
|
352
|
+
positions[vidx++] = hh - i * this._height / this._segmentsH;
|
|
353
|
+
positions[vidx++] = hd;
|
|
354
|
+
thickness[fidx++] = 1;
|
|
355
|
+
}
|
|
356
|
+
for (i = 0; i < this._segmentsW; ++i) {
|
|
357
|
+
positions[vidx++] = i * this._width / this._segmentsW - hw;
|
|
358
|
+
positions[vidx++] = -hh;
|
|
359
|
+
positions[vidx++] = -hd;
|
|
360
|
+
positions[vidx++] = i * this._width / this._segmentsW - hw;
|
|
361
|
+
positions[vidx++] = hh;
|
|
362
|
+
positions[vidx++] = -hd;
|
|
363
|
+
thickness[fidx++] = 1;
|
|
364
|
+
positions[vidx++] = hw - i * this._width / this._segmentsW;
|
|
365
|
+
positions[vidx++] = -hh;
|
|
366
|
+
positions[vidx++] = hd;
|
|
367
|
+
positions[vidx++] = hw - i * this._width / this._segmentsW;
|
|
368
|
+
positions[vidx++] = hh;
|
|
369
|
+
positions[vidx++] = hd;
|
|
370
|
+
thickness[fidx++] = 1;
|
|
371
|
+
}
|
|
372
|
+
//left/right face
|
|
373
|
+
for (i = 0; i < this._segmentsH; ++i) {
|
|
374
|
+
positions[vidx++] = -hw;
|
|
375
|
+
positions[vidx++] = i * this._height / this._segmentsH - hh;
|
|
376
|
+
positions[vidx++] = -hd;
|
|
377
|
+
positions[vidx++] = -hw;
|
|
378
|
+
positions[vidx++] = i * this._height / this._segmentsH - hh;
|
|
379
|
+
positions[vidx++] = hd;
|
|
380
|
+
thickness[fidx++] = 1;
|
|
381
|
+
positions[vidx++] = hw;
|
|
382
|
+
positions[vidx++] = hh - i * this._height / this._segmentsH;
|
|
383
|
+
positions[vidx++] = -hd;
|
|
384
|
+
positions[vidx++] = hw;
|
|
385
|
+
positions[vidx++] = hh - i * this._height / this._segmentsH;
|
|
386
|
+
positions[vidx++] = hd;
|
|
387
|
+
thickness[fidx++] = 1;
|
|
388
|
+
}
|
|
389
|
+
for (i = 0; i < this._segmentsD; ++i) {
|
|
390
|
+
positions[vidx++] = hw;
|
|
391
|
+
positions[vidx++] = -hh;
|
|
392
|
+
positions[vidx++] = i * this._depth / this._segmentsD - hd;
|
|
393
|
+
positions[vidx++] = hw;
|
|
394
|
+
positions[vidx++] = hh;
|
|
395
|
+
positions[vidx++] = i * this._depth / this._segmentsD - hd;
|
|
396
|
+
thickness[fidx++] = 1;
|
|
397
|
+
positions[vidx++] = -hw;
|
|
398
|
+
positions[vidx++] = -hh;
|
|
399
|
+
positions[vidx++] = hd - i * this._depth / this._segmentsD;
|
|
400
|
+
positions[vidx++] = -hw;
|
|
401
|
+
positions[vidx++] = hh;
|
|
402
|
+
positions[vidx++] = hd - i * this._depth / this._segmentsD;
|
|
403
|
+
thickness[fidx++] = 1;
|
|
404
|
+
}
|
|
405
|
+
//top/bottom face
|
|
406
|
+
for (i = 0; i < this._segmentsD; ++i) {
|
|
407
|
+
positions[vidx++] = -hw;
|
|
408
|
+
positions[vidx++] = -hh;
|
|
409
|
+
positions[vidx++] = hd - i * this._depth / this._segmentsD;
|
|
410
|
+
positions[vidx++] = hw;
|
|
411
|
+
positions[vidx++] = -hh;
|
|
412
|
+
positions[vidx++] = hd - i * this._depth / this._segmentsD;
|
|
413
|
+
thickness[fidx++] = 1;
|
|
414
|
+
positions[vidx++] = -hw;
|
|
415
|
+
positions[vidx++] = hh;
|
|
416
|
+
positions[vidx++] = i * this._depth / this._segmentsD - hd;
|
|
417
|
+
positions[vidx++] = hw;
|
|
418
|
+
positions[vidx++] = hh;
|
|
419
|
+
positions[vidx++] = i * this._depth / this._segmentsD - hd;
|
|
420
|
+
thickness[fidx++] = 1;
|
|
421
|
+
}
|
|
422
|
+
for (i = 0; i < this._segmentsW; ++i) {
|
|
423
|
+
positions[vidx++] = hw - i * this._width / this._segmentsW;
|
|
424
|
+
positions[vidx++] = -hh;
|
|
425
|
+
positions[vidx++] = -hd;
|
|
426
|
+
positions[vidx++] = hw - i * this._width / this._segmentsW;
|
|
427
|
+
positions[vidx++] = -hh;
|
|
428
|
+
positions[vidx++] = hd;
|
|
429
|
+
thickness[fidx++] = 1;
|
|
430
|
+
positions[vidx++] = i * this._width / this._segmentsW - hw;
|
|
431
|
+
positions[vidx++] = hh;
|
|
432
|
+
positions[vidx++] = -hd;
|
|
433
|
+
positions[vidx++] = i * this._width / this._segmentsW - hw;
|
|
434
|
+
positions[vidx++] = hh;
|
|
435
|
+
positions[vidx++] = hd;
|
|
436
|
+
thickness[fidx++] = 1;
|
|
437
|
+
}
|
|
438
|
+
// build real data from raw data
|
|
439
|
+
lineGraphics.setPositions(positions);
|
|
440
|
+
lineGraphics.setThickness(thickness);
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
/**
|
|
444
|
+
* @inheritDoc
|
|
445
|
+
*/
|
|
446
|
+
PrimitiveCubePrefab.prototype._pBuildUVs = function (target, elementsType) {
|
|
447
|
+
var i, j, index;
|
|
448
|
+
var uvs;
|
|
449
|
+
var stride;
|
|
450
|
+
var u_tile_dim, v_tile_dim;
|
|
451
|
+
var u_tile_step, v_tile_step;
|
|
452
|
+
var tl0u, tl0v;
|
|
453
|
+
var tl1u, tl1v;
|
|
454
|
+
var du, dv;
|
|
455
|
+
var numVertices;
|
|
456
|
+
if (elementsType == ElementsType.TRIANGLE) {
|
|
457
|
+
numVertices = ((this._segmentsW + 1) * (this._segmentsH + 1) +
|
|
458
|
+
(this._segmentsW + 1) * (this._segmentsD + 1) + (this._segmentsH + 1) * (this._segmentsD + 1)) * 2;
|
|
459
|
+
var triangleGraphics = target;
|
|
460
|
+
if (triangleGraphics.uvs && numVertices == triangleGraphics.numVertices) {
|
|
461
|
+
triangleGraphics.invalidateVertices(triangleGraphics.uvs);
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
triangleGraphics.setUVs(new Float32Array(numVertices * 2));
|
|
465
|
+
}
|
|
466
|
+
uvs = triangleGraphics.uvs.get(numVertices);
|
|
467
|
+
stride = triangleGraphics.uvs.stride;
|
|
468
|
+
if (this._tile6) {
|
|
469
|
+
u_tile_dim = u_tile_step = 1 / 3;
|
|
470
|
+
v_tile_dim = v_tile_step = 1 / 2;
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
u_tile_dim = v_tile_dim = 1;
|
|
474
|
+
u_tile_step = v_tile_step = 0;
|
|
475
|
+
}
|
|
476
|
+
// Create planes two and two, the same way that they were
|
|
477
|
+
// constructed in the buildGraphics() function. First calculate
|
|
478
|
+
// the top-left UV coordinate for both planes, and then loop
|
|
479
|
+
// over the points, calculating the UVs from these numbers.
|
|
480
|
+
// When tile6 is true, the layout is as follows:
|
|
481
|
+
// .-----.-----.-----. (1,1)
|
|
482
|
+
// | Bot | T | Bak |
|
|
483
|
+
// |-----+-----+-----|
|
|
484
|
+
// | L | F | R |
|
|
485
|
+
// (0,0)'-----'-----'-----'
|
|
486
|
+
index = 0;
|
|
487
|
+
// FRONT / BACK
|
|
488
|
+
tl0u = 1 * u_tile_step;
|
|
489
|
+
tl0v = 1 * v_tile_step;
|
|
490
|
+
tl1u = 2 * u_tile_step;
|
|
491
|
+
tl1v = 0 * v_tile_step;
|
|
492
|
+
du = u_tile_dim / this._segmentsW;
|
|
493
|
+
dv = v_tile_dim / this._segmentsH;
|
|
494
|
+
for (i = 0; i <= this._segmentsW; i++) {
|
|
495
|
+
for (j = 0; j <= this._segmentsH; j++) {
|
|
496
|
+
uvs[index] = (tl0u + i * du) * this._scaleU;
|
|
497
|
+
uvs[index + 1] = (tl0v + (v_tile_dim - j * dv)) * this._scaleV;
|
|
498
|
+
index += stride;
|
|
499
|
+
uvs[index] = (tl1u + (u_tile_dim - i * du)) * this._scaleU;
|
|
500
|
+
uvs[index + 1] = (tl1v + (v_tile_dim - j * dv)) * this._scaleV;
|
|
501
|
+
index += stride;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
// TOP / BOTTOM
|
|
505
|
+
tl0u = 1 * u_tile_step;
|
|
506
|
+
tl0v = 0 * v_tile_step;
|
|
507
|
+
tl1u = 0 * u_tile_step;
|
|
508
|
+
tl1v = 0 * v_tile_step;
|
|
509
|
+
du = u_tile_dim / this._segmentsW;
|
|
510
|
+
dv = v_tile_dim / this._segmentsD;
|
|
511
|
+
for (i = 0; i <= this._segmentsW; i++) {
|
|
512
|
+
for (j = 0; j <= this._segmentsD; j++) {
|
|
513
|
+
uvs[index] = (tl0u + i * du) * this._scaleU;
|
|
514
|
+
uvs[index + 1] = (tl0v + (v_tile_dim - j * dv)) * this._scaleV;
|
|
515
|
+
index += stride;
|
|
516
|
+
uvs[index] = (tl1u + i * du) * this._scaleU;
|
|
517
|
+
uvs[index + 1] = (tl1v + j * dv) * this._scaleV;
|
|
518
|
+
index += stride;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
// LEFT / RIGHT
|
|
522
|
+
tl0u = 0 * u_tile_step;
|
|
523
|
+
tl0v = 1 * v_tile_step;
|
|
524
|
+
tl1u = 2 * u_tile_step;
|
|
525
|
+
tl1v = 1 * v_tile_step;
|
|
526
|
+
du = u_tile_dim / this._segmentsD;
|
|
527
|
+
dv = v_tile_dim / this._segmentsH;
|
|
528
|
+
for (i = 0; i <= this._segmentsD; i++) {
|
|
529
|
+
for (j = 0; j <= this._segmentsH; j++) {
|
|
530
|
+
uvs[index] = (tl0u + i * du) * this._scaleU;
|
|
531
|
+
uvs[index + 1] = (tl0v + (v_tile_dim - j * dv)) * this._scaleV;
|
|
532
|
+
index += stride;
|
|
533
|
+
uvs[index] = (tl1u + (u_tile_dim - i * du)) * this._scaleU;
|
|
534
|
+
uvs[index + 1] = (tl1v + (v_tile_dim - j * dv)) * this._scaleV;
|
|
535
|
+
index += stride;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
else if (elementsType == ElementsType.LINE) {
|
|
540
|
+
//nothing to do here
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
return PrimitiveCubePrefab;
|
|
544
|
+
}(PrimitivePrefabBase));
|
|
545
|
+
export { PrimitiveCubePrefab };
|