@antv/g-webgpu 0.5.5 → 1.0.1
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/LICENSE +21 -0
- package/README.md +0 -53
- package/dist/index.umd.min.js +16 -0
- package/es/ContextRegisterPlugin.d.ts +7 -0
- package/es/ContextRegisterPlugin.js +28 -0
- package/es/WebGLContextService.d.ts +18 -0
- package/es/WebGLContextService.js +99 -0
- package/es/index.d.ts +10 -7
- package/es/index.js +31 -8
- package/lib/ContextRegisterPlugin.d.ts +7 -0
- package/lib/ContextRegisterPlugin.js +37 -0
- package/lib/WebGLContextService.d.ts +18 -0
- package/lib/WebGLContextService.js +107 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +43 -43
- package/package.json +37 -31
- package/CHANGELOG.md +0 -89
- package/es/Kernel.d.ts +0 -21
- package/es/Kernel.js +0 -331
- package/es/Kernel.js.map +0 -1
- package/es/Renderer.d.ts +0 -24
- package/es/Renderer.js +0 -341
- package/es/Renderer.js.map +0 -1
- package/es/Scene.d.ts +0 -11
- package/es/Scene.js +0 -54
- package/es/Scene.js.map +0 -1
- package/es/View.d.ts +0 -20
- package/es/View.js +0 -86
- package/es/View.js.map +0 -1
- package/es/World.d.ts +0 -49
- package/es/World.js +0 -283
- package/es/World.js.map +0 -1
- package/es/camera/Camera.d.ts +0 -252
- package/es/camera/Camera.js +0 -831
- package/es/camera/Camera.js.map +0 -1
- package/es/camera/Landmark.d.ts +0 -28
- package/es/camera/Landmark.js +0 -86
- package/es/camera/Landmark.js.map +0 -1
- package/es/geometry/Box.d.ts +0 -11
- package/es/geometry/Box.js +0 -180
- package/es/geometry/Box.js.map +0 -1
- package/es/geometry/Merged.d.ts +0 -8
- package/es/geometry/Merged.js +0 -91
- package/es/geometry/Merged.js.map +0 -1
- package/es/geometry/Plane.d.ts +0 -10
- package/es/geometry/Plane.js +0 -112
- package/es/geometry/Plane.js.map +0 -1
- package/es/geometry/Sphere.d.ts +0 -9
- package/es/geometry/Sphere.js +0 -121
- package/es/geometry/Sphere.js.map +0 -1
- package/es/geometry/index.d.ts +0 -19
- package/es/geometry/index.js +0 -59
- package/es/geometry/index.js.map +0 -1
- package/es/glsl.d.js +0 -2
- package/es/glsl.d.js.map +0 -1
- package/es/index.js.map +0 -1
- package/es/material/basic/index.d.ts +0 -10
- package/es/material/basic/index.js +0 -108
- package/es/material/basic/index.js.map +0 -1
- package/es/material/index.d.ts +0 -16
- package/es/material/index.js +0 -60
- package/es/material/index.js.map +0 -1
- package/es/renderable/Renderable.d.ts +0 -41
- package/es/renderable/Renderable.js +0 -169
- package/es/renderable/Renderable.js.map +0 -1
- package/es/renderable/grid/index.d.ts +0 -17
- package/es/renderable/grid/index.js +0 -133
- package/es/renderable/grid/index.js.map +0 -1
- package/es/renderable/line/index.d.ts +0 -23
- package/es/renderable/line/index.js +0 -231
- package/es/renderable/line/index.js.map +0 -1
- package/es/renderable/point/index.d.ts +0 -29
- package/es/renderable/point/index.js +0 -241
- package/es/renderable/point/index.js.map +0 -1
- package/es/texture/Cache.d.ts +0 -6
- package/es/texture/Cache.js +0 -28
- package/es/texture/Cache.js.map +0 -1
- package/es/texture/Texture2D.d.ts +0 -13
- package/es/texture/Texture2D.js +0 -126
- package/es/texture/Texture2D.js.map +0 -1
- package/es/utils/canvas.d.ts +0 -1
- package/es/utils/canvas.js +0 -8
- package/es/utils/canvas.js.map +0 -1
- package/es/utils/is-array.d.ts +0 -2
- package/es/utils/is-array.js +0 -5
- package/es/utils/is-array.js.map +0 -1
- package/es/utils/is-number.d.ts +0 -1
- package/es/utils/is-number.js +0 -4
- package/es/utils/is-number.js.map +0 -1
- package/es/utils/is-type.d.ts +0 -2
- package/es/utils/is-type.js +0 -8
- package/es/utils/is-type.js.map +0 -1
- package/es/utils/is-typedarray.d.ts +0 -27
- package/es/utils/is-typedarray.js +0 -99
- package/es/utils/is-typedarray.js.map +0 -1
- package/es/utils/math.d.ts +0 -3
- package/es/utils/math.js +0 -24
- package/es/utils/math.js.map +0 -1
- package/es/utils/picking.d.ts +0 -1
- package/es/utils/picking.js +0 -4
- package/es/utils/picking.js.map +0 -1
- package/es/utils/polyline-normals.d.ts +0 -6
- package/es/utils/polyline-normals.js +0 -129
- package/es/utils/polyline-normals.js.map +0 -1
- package/es/utils/typedarray.d.ts +0 -1
- package/es/utils/typedarray.js +0 -29
- package/es/utils/typedarray.js.map +0 -1
- package/lib/Kernel.js +0 -352
- package/lib/Kernel.js.map +0 -1
- package/lib/Renderer.js +0 -354
- package/lib/Renderer.js.map +0 -1
- package/lib/Scene.js +0 -64
- package/lib/Scene.js.map +0 -1
- package/lib/View.js +0 -99
- package/lib/View.js.map +0 -1
- package/lib/World.js +0 -313
- package/lib/World.js.map +0 -1
- package/lib/camera/Camera.js +0 -900
- package/lib/camera/Camera.js.map +0 -1
- package/lib/camera/Landmark.js +0 -95
- package/lib/camera/Landmark.js.map +0 -1
- package/lib/geometry/Box.js +0 -205
- package/lib/geometry/Box.js.map +0 -1
- package/lib/geometry/Merged.js +0 -110
- package/lib/geometry/Merged.js.map +0 -1
- package/lib/geometry/Plane.js +0 -127
- package/lib/geometry/Plane.js.map +0 -1
- package/lib/geometry/Sphere.js +0 -136
- package/lib/geometry/Sphere.js.map +0 -1
- package/lib/geometry/index.js +0 -71
- package/lib/geometry/index.js.map +0 -1
- package/lib/glsl.d.js +0 -2
- package/lib/glsl.d.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/material/basic/index.js +0 -125
- package/lib/material/basic/index.js.map +0 -1
- package/lib/material/index.js +0 -72
- package/lib/material/index.js.map +0 -1
- package/lib/renderable/Renderable.js +0 -178
- package/lib/renderable/Renderable.js.map +0 -1
- package/lib/renderable/grid/index.js +0 -148
- package/lib/renderable/grid/index.js.map +0 -1
- package/lib/renderable/line/index.js +0 -248
- package/lib/renderable/line/index.js.map +0 -1
- package/lib/renderable/point/index.js +0 -259
- package/lib/renderable/point/index.js.map +0 -1
- package/lib/texture/Cache.js +0 -38
- package/lib/texture/Cache.js.map +0 -1
- package/lib/texture/Texture2D.js +0 -142
- package/lib/texture/Texture2D.js.map +0 -1
- package/lib/utils/canvas.js +0 -15
- package/lib/utils/canvas.js.map +0 -1
- package/lib/utils/is-array.js +0 -17
- package/lib/utils/is-array.js.map +0 -1
- package/lib/utils/is-number.js +0 -11
- package/lib/utils/is-number.js.map +0 -1
- package/lib/utils/is-type.js +0 -15
- package/lib/utils/is-type.js.map +0 -1
- package/lib/utils/is-typedarray.js +0 -109
- package/lib/utils/is-typedarray.js.map +0 -1
- package/lib/utils/math.js +0 -35
- package/lib/utils/math.js.map +0 -1
- package/lib/utils/picking.js +0 -11
- package/lib/utils/picking.js.map +0 -1
- package/lib/utils/polyline-normals.js +0 -137
- package/lib/utils/polyline-normals.js.map +0 -1
- package/lib/utils/typedarray.js +0 -36
- package/lib/utils/typedarray.js.map +0 -1
package/es/World.js
DELETED
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
-
import _initializerDefineProperty from "@babel/runtime/helpers/initializerDefineProperty";
|
|
5
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
6
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
7
|
-
import _applyDecoratedDescriptor from "@babel/runtime/helpers/applyDecoratedDescriptor";
|
|
8
|
-
import _initializerWarningHelper from "@babel/runtime/helpers/initializerWarningHelper";
|
|
9
|
-
|
|
10
|
-
var _dec, _dec2, _class, _class2, _descriptor, _temp;
|
|
11
|
-
|
|
12
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
-
|
|
14
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
15
|
-
|
|
16
|
-
// tslint:disable-next-line:no-reference
|
|
17
|
-
/// <reference path="../../../node_modules/@webgpu/types/dist/index.d.ts" />
|
|
18
|
-
import { createEntity as _createEntity, createWorldContainer, IDENTIFIER } from '@antv/g-webgpu-core';
|
|
19
|
-
import { WebGLEngine, WebGPUEngine } from '@antv/g-webgpu-engine'; // tslint:disable-next-line:no-submodule-imports
|
|
20
|
-
|
|
21
|
-
import * as WebGPUConstants from '@webgpu/types/dist/constants';
|
|
22
|
-
import { inject, injectable } from 'inversify';
|
|
23
|
-
import { Camera } from './camera/Camera';
|
|
24
|
-
import { Geometry } from './geometry';
|
|
25
|
-
import { Box } from './geometry/Box';
|
|
26
|
-
import { Merged } from './geometry/Merged';
|
|
27
|
-
import { Plane } from './geometry/Plane';
|
|
28
|
-
import { Sphere } from './geometry/Sphere';
|
|
29
|
-
import { Kernel } from './Kernel';
|
|
30
|
-
import { Material } from './material';
|
|
31
|
-
import { Basic } from './material/basic';
|
|
32
|
-
import { Grid } from './renderable/grid';
|
|
33
|
-
import { Line } from './renderable/line';
|
|
34
|
-
import { Point } from './renderable/point';
|
|
35
|
-
import { Renderable } from './renderable/Renderable';
|
|
36
|
-
import { Renderer } from './Renderer';
|
|
37
|
-
import { Scene } from './Scene';
|
|
38
|
-
import { TextureCache } from './texture/Cache';
|
|
39
|
-
import { Texture2D } from './texture/Texture2D';
|
|
40
|
-
import { createCanvas } from './utils/canvas';
|
|
41
|
-
import { View } from './View';
|
|
42
|
-
export var World = (_dec = injectable(), _dec2 = inject(IDENTIFIER.ConfigService), _dec(_class = (_class2 = (_temp = /*#__PURE__*/function () {
|
|
43
|
-
function World() {
|
|
44
|
-
_classCallCheck(this, World);
|
|
45
|
-
|
|
46
|
-
_initializerDefineProperty(this, "configService", _descriptor, this);
|
|
47
|
-
|
|
48
|
-
this.container = void 0;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
_createClass(World, [{
|
|
52
|
-
key: "getEngine",
|
|
53
|
-
value: function () {
|
|
54
|
-
var _getEngine = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
55
|
-
var engine, _this$configService$g, canvas, engineOptions;
|
|
56
|
-
|
|
57
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
58
|
-
while (1) {
|
|
59
|
-
switch (_context.prev = _context.next) {
|
|
60
|
-
case 0:
|
|
61
|
-
engine = this.container.get(IDENTIFIER.RenderEngine);
|
|
62
|
-
_this$configService$g = this.configService.get(), canvas = _this$configService$g.canvas, engineOptions = _this$configService$g.engineOptions;
|
|
63
|
-
_context.next = 4;
|
|
64
|
-
return engine.init(_objectSpread({
|
|
65
|
-
canvas: canvas || createCanvas(),
|
|
66
|
-
swapChainFormat: WebGPUConstants.TextureFormat.BGRA8Unorm,
|
|
67
|
-
antialiasing: false
|
|
68
|
-
}, engineOptions));
|
|
69
|
-
|
|
70
|
-
case 4:
|
|
71
|
-
return _context.abrupt("return", engine);
|
|
72
|
-
|
|
73
|
-
case 5:
|
|
74
|
-
case "end":
|
|
75
|
-
return _context.stop();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}, _callee, this);
|
|
79
|
-
}));
|
|
80
|
-
|
|
81
|
-
function getEngine() {
|
|
82
|
-
return _getEngine.apply(this, arguments);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return getEngine;
|
|
86
|
-
}()
|
|
87
|
-
/**
|
|
88
|
-
* get transform component
|
|
89
|
-
* @param entity
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
}, {
|
|
93
|
-
key: "getTransformComponent",
|
|
94
|
-
value: function getTransformComponent(entity) {
|
|
95
|
-
var manager = this.container.get(IDENTIFIER.TransformComponentManager);
|
|
96
|
-
return manager.getComponentByEntity(entity);
|
|
97
|
-
}
|
|
98
|
-
}, {
|
|
99
|
-
key: "getMeshComponent",
|
|
100
|
-
value: function getMeshComponent(entity) {
|
|
101
|
-
var manager = this.container.get(IDENTIFIER.MeshComponentManager);
|
|
102
|
-
return manager.getComponentByEntity(entity);
|
|
103
|
-
}
|
|
104
|
-
}, {
|
|
105
|
-
key: "setConfig",
|
|
106
|
-
value: function setConfig(config) {
|
|
107
|
-
this.configService.set(config);
|
|
108
|
-
}
|
|
109
|
-
}, {
|
|
110
|
-
key: "setContainer",
|
|
111
|
-
value: function setContainer(container) {
|
|
112
|
-
this.container = container;
|
|
113
|
-
}
|
|
114
|
-
}, {
|
|
115
|
-
key: "getContainer",
|
|
116
|
-
value: function getContainer() {
|
|
117
|
-
return this.container;
|
|
118
|
-
}
|
|
119
|
-
}, {
|
|
120
|
-
key: "createEntity",
|
|
121
|
-
value: function createEntity() {
|
|
122
|
-
return _createEntity();
|
|
123
|
-
}
|
|
124
|
-
}, {
|
|
125
|
-
key: "createScene",
|
|
126
|
-
value: function createScene() {
|
|
127
|
-
return this.container.get(Scene);
|
|
128
|
-
}
|
|
129
|
-
}, {
|
|
130
|
-
key: "createCamera",
|
|
131
|
-
value: function createCamera() {
|
|
132
|
-
return this.container.get(Camera);
|
|
133
|
-
}
|
|
134
|
-
}, {
|
|
135
|
-
key: "createView",
|
|
136
|
-
value: function createView() {
|
|
137
|
-
return this.container.get(View);
|
|
138
|
-
} // public createLight(type: string,) {
|
|
139
|
-
// return this.container.getNamed(IDENTIFIER.Light, type)
|
|
140
|
-
// }
|
|
141
|
-
|
|
142
|
-
}, {
|
|
143
|
-
key: "createRenderable",
|
|
144
|
-
value: function createRenderable(type, config) {
|
|
145
|
-
var renderable = type ? this.container.getNamed(IDENTIFIER.Renderable, type) : this.container.get(Renderable);
|
|
146
|
-
|
|
147
|
-
var entity = _createEntity();
|
|
148
|
-
|
|
149
|
-
renderable.setConfig(config || {});
|
|
150
|
-
renderable.setEntity(entity);
|
|
151
|
-
return renderable;
|
|
152
|
-
}
|
|
153
|
-
}, {
|
|
154
|
-
key: "createGeometry",
|
|
155
|
-
value: function createGeometry(type, config) {
|
|
156
|
-
var geometry = this.container.getNamed(IDENTIFIER.Geometry, type);
|
|
157
|
-
|
|
158
|
-
var entity = _createEntity();
|
|
159
|
-
|
|
160
|
-
geometry.setConfig(config || {});
|
|
161
|
-
geometry.setEntity(entity);
|
|
162
|
-
return geometry.getComponent();
|
|
163
|
-
}
|
|
164
|
-
}, {
|
|
165
|
-
key: "createMaterial",
|
|
166
|
-
value: function createMaterial(type, config) {
|
|
167
|
-
var material = this.container.getNamed(IDENTIFIER.Material, type);
|
|
168
|
-
|
|
169
|
-
var entity = _createEntity();
|
|
170
|
-
|
|
171
|
-
material.setConfig(config || {});
|
|
172
|
-
material.setEntity(entity, type);
|
|
173
|
-
return material.getComponent();
|
|
174
|
-
}
|
|
175
|
-
}, {
|
|
176
|
-
key: "createTexture2D",
|
|
177
|
-
value: function createTexture2D(config) {
|
|
178
|
-
var texture = this.container.get(Texture2D);
|
|
179
|
-
texture.setConfig(config);
|
|
180
|
-
return texture;
|
|
181
|
-
}
|
|
182
|
-
}, {
|
|
183
|
-
key: "createBufferGeometry",
|
|
184
|
-
value: function createBufferGeometry(params) {
|
|
185
|
-
var geometrySystem = this.container.getNamed(IDENTIFIER.Systems, IDENTIFIER.GeometrySystem);
|
|
186
|
-
return geometrySystem.createBufferGeometry(params);
|
|
187
|
-
}
|
|
188
|
-
}, {
|
|
189
|
-
key: "createInstancedBufferGeometry",
|
|
190
|
-
value: function createInstancedBufferGeometry(params) {
|
|
191
|
-
var geometrySystem = this.container.getNamed(IDENTIFIER.Systems, IDENTIFIER.GeometrySystem);
|
|
192
|
-
return geometrySystem.createInstancedBufferGeometry(params);
|
|
193
|
-
}
|
|
194
|
-
}, {
|
|
195
|
-
key: "createShaderMaterial",
|
|
196
|
-
value: function createShaderMaterial(params) {
|
|
197
|
-
var materialSystem = this.container.getNamed(IDENTIFIER.Systems, IDENTIFIER.MaterialSystem);
|
|
198
|
-
return materialSystem.createShaderMaterial(params);
|
|
199
|
-
}
|
|
200
|
-
}, {
|
|
201
|
-
key: "createKernel",
|
|
202
|
-
value: function createKernel(precompiledBundle) {
|
|
203
|
-
var kernel = this.container.get(Kernel);
|
|
204
|
-
|
|
205
|
-
if (typeof precompiledBundle === 'string') {
|
|
206
|
-
kernel.setBundle(JSON.parse(precompiledBundle));
|
|
207
|
-
} else {
|
|
208
|
-
kernel.setBundle(precompiledBundle);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
kernel.init();
|
|
212
|
-
return kernel;
|
|
213
|
-
}
|
|
214
|
-
}, {
|
|
215
|
-
key: "createRenderer",
|
|
216
|
-
value: function createRenderer() {
|
|
217
|
-
var renderer = this.container.get(Renderer);
|
|
218
|
-
renderer.container = this.container;
|
|
219
|
-
renderer.init();
|
|
220
|
-
return renderer;
|
|
221
|
-
}
|
|
222
|
-
}, {
|
|
223
|
-
key: "destroy",
|
|
224
|
-
value: function destroy() {
|
|
225
|
-
var systems = this.container.getAll(IDENTIFIER.Systems);
|
|
226
|
-
systems.forEach(function (system) {
|
|
227
|
-
if (system.tearDown) {
|
|
228
|
-
system.tearDown();
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
var engine = this.container.get(IDENTIFIER.RenderEngine);
|
|
232
|
-
engine.destroy();
|
|
233
|
-
var interactor = this.container.get(IDENTIFIER.InteractorService);
|
|
234
|
-
interactor.destroy();
|
|
235
|
-
}
|
|
236
|
-
}], [{
|
|
237
|
-
key: "create",
|
|
238
|
-
value: function create() {
|
|
239
|
-
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
240
|
-
var worldContainer = createWorldContainer(); // bind render engine, fallback to WebGL
|
|
241
|
-
|
|
242
|
-
var engineClazz = !navigator.gpu ? WebGLEngine : WebGPUEngine;
|
|
243
|
-
|
|
244
|
-
if (!worldContainer.isBound(IDENTIFIER.RenderEngine)) {
|
|
245
|
-
worldContainer.bind(IDENTIFIER.RenderEngine) // @ts-ignore
|
|
246
|
-
.to(engineClazz).inSingletonScope();
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
worldContainer.bind(Renderer).toSelf();
|
|
250
|
-
worldContainer.bind(Kernel).toSelf();
|
|
251
|
-
worldContainer.bind(Renderable).toSelf();
|
|
252
|
-
worldContainer.bind(View).toSelf();
|
|
253
|
-
worldContainer.bind(Camera).toSelf();
|
|
254
|
-
worldContainer.bind(Scene).toSelf();
|
|
255
|
-
worldContainer.bind(World).toSelf();
|
|
256
|
-
worldContainer.bind(TextureCache).toSelf();
|
|
257
|
-
worldContainer.bind(Texture2D).toSelf(); // bind geometries
|
|
258
|
-
|
|
259
|
-
worldContainer.bind(IDENTIFIER.Geometry).to(Box).whenTargetNamed(Geometry.BOX);
|
|
260
|
-
worldContainer.bind(IDENTIFIER.Geometry).to(Sphere).whenTargetNamed(Geometry.SPHERE);
|
|
261
|
-
worldContainer.bind(IDENTIFIER.Geometry).to(Plane).whenTargetNamed(Geometry.PLANE);
|
|
262
|
-
worldContainer.bind(IDENTIFIER.Geometry).to(Merged).whenTargetNamed(Geometry.MERGED); // bind materials
|
|
263
|
-
|
|
264
|
-
worldContainer.bind(IDENTIFIER.Material).to(Basic).whenTargetNamed(Material.BASIC); // bind renderables
|
|
265
|
-
|
|
266
|
-
worldContainer.bind(IDENTIFIER.Renderable).to(Point).whenTargetNamed(Renderable.POINT);
|
|
267
|
-
worldContainer.bind(IDENTIFIER.Renderable).to(Line).whenTargetNamed(Renderable.LINE);
|
|
268
|
-
worldContainer.bind(IDENTIFIER.Renderable).to(Grid).whenTargetNamed(Renderable.GRID);
|
|
269
|
-
var world = worldContainer.get(World);
|
|
270
|
-
world.setContainer(worldContainer);
|
|
271
|
-
world.setConfig(config);
|
|
272
|
-
return world;
|
|
273
|
-
}
|
|
274
|
-
}]);
|
|
275
|
-
|
|
276
|
-
return World;
|
|
277
|
-
}(), _temp), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "configService", [_dec2], {
|
|
278
|
-
configurable: true,
|
|
279
|
-
enumerable: true,
|
|
280
|
-
writable: true,
|
|
281
|
-
initializer: null
|
|
282
|
-
})), _class2)) || _class);
|
|
283
|
-
//# sourceMappingURL=World.js.map
|
package/es/World.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/World.ts"],"names":["createEntity","createWorldContainer","IDENTIFIER","WebGLEngine","WebGPUEngine","WebGPUConstants","inject","injectable","Camera","Geometry","Box","Merged","Plane","Sphere","Kernel","Material","Basic","Grid","Line","Point","Renderable","Renderer","Scene","TextureCache","Texture2D","createCanvas","View","World","ConfigService","container","engine","get","RenderEngine","configService","canvas","engineOptions","init","swapChainFormat","TextureFormat","BGRA8Unorm","antialiasing","entity","manager","TransformComponentManager","getComponentByEntity","MeshComponentManager","config","set","type","renderable","getNamed","setConfig","setEntity","geometry","getComponent","material","texture","params","geometrySystem","Systems","GeometrySystem","createBufferGeometry","createInstancedBufferGeometry","materialSystem","MaterialSystem","createShaderMaterial","precompiledBundle","kernel","setBundle","JSON","parse","renderer","systems","getAll","forEach","system","tearDown","destroy","interactor","InteractorService","worldContainer","engineClazz","navigator","gpu","isBound","bind","to","inSingletonScope","toSelf","whenTargetNamed","BOX","SPHERE","PLANE","MERGED","BASIC","POINT","LINE","GRID","world","setContainer"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA,SAEEA,YAAY,IAAZA,aAFF,EAGEC,oBAHF,EASEC,UATF,QAmBO,qBAnBP;AAoBA,SAASC,WAAT,EAAsBC,YAAtB,QAA0C,uBAA1C,C,CACA;;AACA,OAAO,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CAGmBrE,UAAU,CAAC2E,KAH9B;AAIAf,MAAAA,cAAc,CACXK,IADH,CAC8BnF,UAAU,CAACkB,UADzC,EAEGkE,EAFH,CAEMpE,IAFN,EAGGuE,eAHH,CAGmBrE,UAAU,CAAC4E,IAH9B;AAIAhB,MAAAA,cAAc,CACXK,IADH,CAC8BnF,UAAU,CAACkB,UADzC,EAEGkE,EAFH,CAEMrE,IAFN,EAGGwE,eAHH,CAGmBrE,UAAU,CAAC6E,IAH9B;AAKA,UAAMC,KAAK,GAAGlB,cAAc,CAACjD,GAAf,CAAmBJ,KAAnB,CAAd;AACAuE,MAAAA,KAAK,CAACC,YAAN,CAAmBnB,cAAnB;AACAkB,MAAAA,KAAK,CAAC/C,SAAN,CAAgBL,MAAhB;AACA,aAAOoD,KAAP;AACD;AAlEH;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["// tslint:disable-next-line:no-reference\n/// <reference path=\"../../../node_modules/@webgpu/types/dist/index.d.ts\" />\nimport {\n ComponentManager,\n createEntity,\n createWorldContainer,\n Entity,\n GeometrySystem,\n // container,\n IConfig,\n IConfigService,\n IDENTIFIER,\n IInteractorService,\n IRendererService,\n ISystem,\n ITexture2D,\n ITexture2DInitializationOptions,\n KernelBundle,\n MaterialSystem,\n MeshComponent,\n TransformComponent,\n} from '@antv/g-webgpu-core';\nimport { WebGLEngine, WebGPUEngine } from '@antv/g-webgpu-engine';\n// tslint:disable-next-line:no-submodule-imports\nimport * as WebGPUConstants from '@webgpu/types/dist/constants';\nimport { Container, inject, injectable } from 'inversify';\nimport { Camera } from './camera/Camera';\nimport { Geometry, IGeometry } from './geometry';\nimport { Box } from './geometry/Box';\nimport { Merged } from './geometry/Merged';\nimport { Plane } from './geometry/Plane';\nimport { Sphere } from './geometry/Sphere';\nimport { Kernel } from './Kernel';\nimport { IMaterial, Material } from './material';\nimport { Basic } from './material/basic';\nimport { Grid } from './renderable/grid';\nimport { Line } from './renderable/line';\nimport { Point } from './renderable/point';\nimport { IRenderable, Renderable } from './renderable/Renderable';\nimport { Renderer } from './Renderer';\nimport { Scene } from './Scene';\nimport { TextureCache } from './texture/Cache';\nimport { Texture2D } from './texture/Texture2D';\nimport { createCanvas } from './utils/canvas';\nimport { View } from './View';\n\n@injectable()\nexport class World {\n public static create(config: Partial<IConfig> = {}) {\n const worldContainer = createWorldContainer();\n\n // bind render engine, fallback to WebGL\n const engineClazz = !navigator.gpu ? WebGLEngine : WebGPUEngine;\n if (!worldContainer.isBound(IDENTIFIER.RenderEngine)) {\n worldContainer\n .bind<IRendererService>(IDENTIFIER.RenderEngine)\n // @ts-ignore\n .to(engineClazz)\n .inSingletonScope();\n }\n\n worldContainer.bind(Renderer).toSelf();\n worldContainer.bind(Kernel).toSelf();\n worldContainer.bind(Renderable).toSelf();\n worldContainer.bind(View).toSelf();\n worldContainer.bind(Camera).toSelf();\n worldContainer.bind(Scene).toSelf();\n worldContainer.bind(World).toSelf();\n worldContainer.bind(TextureCache).toSelf();\n worldContainer.bind(Texture2D).toSelf();\n\n // bind geometries\n worldContainer\n .bind<IGeometry<unknown>>(IDENTIFIER.Geometry)\n .to(Box)\n .whenTargetNamed(Geometry.BOX);\n worldContainer\n .bind<IGeometry<unknown>>(IDENTIFIER.Geometry)\n .to(Sphere)\n .whenTargetNamed(Geometry.SPHERE);\n worldContainer\n .bind<IGeometry<unknown>>(IDENTIFIER.Geometry)\n .to(Plane)\n .whenTargetNamed(Geometry.PLANE);\n worldContainer\n .bind<IGeometry<unknown>>(IDENTIFIER.Geometry)\n .to(Merged)\n .whenTargetNamed(Geometry.MERGED);\n\n // bind materials\n worldContainer\n .bind<IMaterial<unknown>>(IDENTIFIER.Material)\n .to(Basic)\n .whenTargetNamed(Material.BASIC);\n\n // bind renderables\n worldContainer\n .bind<IRenderable<unknown>>(IDENTIFIER.Renderable)\n .to(Point)\n .whenTargetNamed(Renderable.POINT);\n worldContainer\n .bind<IRenderable<unknown>>(IDENTIFIER.Renderable)\n .to(Line)\n .whenTargetNamed(Renderable.LINE);\n worldContainer\n .bind<IRenderable<unknown>>(IDENTIFIER.Renderable)\n .to(Grid)\n .whenTargetNamed(Renderable.GRID);\n\n const world = worldContainer.get(World);\n world.setContainer(worldContainer);\n world.setConfig(config);\n return world;\n }\n\n @inject(IDENTIFIER.ConfigService)\n private readonly configService: IConfigService;\n\n private container: Container;\n\n public async getEngine() {\n const engine = this.container.get<IRendererService>(\n IDENTIFIER.RenderEngine,\n );\n const { canvas, engineOptions } = this.configService.get();\n await engine.init({\n canvas: canvas || createCanvas(),\n swapChainFormat: WebGPUConstants.TextureFormat.BGRA8Unorm,\n antialiasing: false,\n ...engineOptions,\n });\n return engine;\n }\n\n /**\n * get transform component\n * @param entity\n */\n public getTransformComponent(entity: Entity) {\n const manager = this.container.get<ComponentManager<TransformComponent>>(\n IDENTIFIER.TransformComponentManager,\n );\n return manager.getComponentByEntity(entity);\n }\n\n public getMeshComponent(entity: Entity) {\n const manager = this.container.get<ComponentManager<MeshComponent>>(\n IDENTIFIER.MeshComponentManager,\n );\n return manager.getComponentByEntity(entity);\n }\n\n public setConfig(config: Partial<IConfig>) {\n this.configService.set(config);\n }\n\n public setContainer(container: Container) {\n this.container = container;\n }\n\n public getContainer() {\n return this.container;\n }\n\n public createEntity() {\n return createEntity();\n }\n\n public createScene() {\n return this.container.get(Scene);\n }\n\n public createCamera() {\n return this.container.get(Camera);\n }\n\n public createView() {\n return this.container.get(View);\n }\n\n // public createLight(type: string,) {\n // return this.container.getNamed(IDENTIFIER.Light, type)\n // }\n\n public createRenderable<T>(type?: string, config?: T) {\n const renderable: Renderable = type\n ? this.container.getNamed(IDENTIFIER.Renderable, type)\n : this.container.get(Renderable);\n const entity = createEntity();\n renderable.setConfig(config || {});\n renderable.setEntity(entity);\n return renderable;\n }\n\n public createGeometry<T>(type: string, config?: T) {\n const geometry: Geometry = this.container.getNamed(\n IDENTIFIER.Geometry,\n type,\n );\n const entity = createEntity();\n geometry.setConfig(config || {});\n geometry.setEntity(entity);\n return geometry.getComponent();\n }\n\n public createMaterial<T>(type: string, config?: T) {\n const material: Material = this.container.getNamed(\n IDENTIFIER.Material,\n type,\n );\n const entity = createEntity();\n material.setConfig(config || {});\n material.setEntity(entity, type);\n return material.getComponent();\n }\n\n public createTexture2D(\n config: ITexture2DInitializationOptions & { url: string },\n ) {\n const texture = this.container.get(Texture2D);\n texture.setConfig(config);\n return texture;\n }\n\n public createBufferGeometry(params?: { vertexCount: number }) {\n const geometrySystem = this.container.getNamed<GeometrySystem>(\n IDENTIFIER.Systems,\n IDENTIFIER.GeometrySystem,\n );\n return geometrySystem.createBufferGeometry(params);\n }\n\n public createInstancedBufferGeometry(params: {\n maxInstancedCount: number;\n vertexCount: number;\n }) {\n const geometrySystem = this.container.getNamed<GeometrySystem>(\n IDENTIFIER.Systems,\n IDENTIFIER.GeometrySystem,\n );\n return geometrySystem.createInstancedBufferGeometry(params);\n }\n\n public createShaderMaterial(params: {\n vertexShader: string;\n fragmentShader: string;\n }) {\n const materialSystem = this.container.getNamed<MaterialSystem>(\n IDENTIFIER.Systems,\n IDENTIFIER.MaterialSystem,\n );\n return materialSystem.createShaderMaterial(params);\n }\n\n public createKernel(precompiledBundle: KernelBundle | string) {\n const kernel = this.container.get(Kernel);\n if (typeof precompiledBundle === 'string') {\n kernel.setBundle(JSON.parse(precompiledBundle));\n } else {\n kernel.setBundle(precompiledBundle);\n }\n kernel.init();\n return kernel;\n }\n\n public createRenderer() {\n const renderer = this.container.get(Renderer);\n renderer.container = this.container;\n renderer.init();\n return renderer;\n }\n\n public destroy() {\n const systems = this.container.getAll<ISystem>(IDENTIFIER.Systems);\n systems.forEach((system) => {\n if (system.tearDown) {\n system.tearDown();\n }\n });\n const engine = this.container.get<IRendererService>(\n IDENTIFIER.RenderEngine,\n );\n engine.destroy();\n const interactor = this.container.get<IInteractorService>(\n IDENTIFIER.InteractorService,\n );\n interactor.destroy();\n }\n}\n"],"file":"World.js"}
|
package/es/camera/Camera.d.ts
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import { Frustum, ICamera, IInteractorService } from '@antv/g-webgpu-core';
|
|
2
|
-
import { mat4, vec3 } from 'gl-matrix';
|
|
3
|
-
import Landmark from './Landmark';
|
|
4
|
-
export declare enum CAMERA_TYPE {
|
|
5
|
-
ORBITING = "ORBITING",
|
|
6
|
-
EXPLORING = "EXPLORING",
|
|
7
|
-
TRACKING = "TRACKING"
|
|
8
|
-
}
|
|
9
|
-
export declare enum CAMERA_TRACKING_MODE {
|
|
10
|
-
DEFAULT = "DEFAULT",
|
|
11
|
-
ROTATIONAL = "ROTATIONAL",
|
|
12
|
-
TRANSLATIONAL = "TRANSLATIONAL",
|
|
13
|
-
CINEMATIC = "CINEMATIC"
|
|
14
|
-
}
|
|
15
|
-
export declare enum CAMERA_PROJECTION_MODE {
|
|
16
|
-
ORTHOGRAPHIC = "ORTHOGRAPHIC",
|
|
17
|
-
PERSPECTIVE = "PERSPECTIVE"
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* 参考「WebGL Insights - 23.Designing Cameras for WebGL Applications」,基于 Responsible Camera 思路设计
|
|
21
|
-
* 保存相机参数,定义相机动作:
|
|
22
|
-
* 1. dolly 沿 n 轴移动
|
|
23
|
-
* 2. pan 沿 u v 轴移动
|
|
24
|
-
* 3. rotate 以方位角旋转
|
|
25
|
-
* 4. 移动到 Landmark,具有平滑的动画效果,其间禁止其他用户交互
|
|
26
|
-
*/
|
|
27
|
-
export declare class Camera implements ICamera {
|
|
28
|
-
static ProjectionMode: {
|
|
29
|
-
ORTHOGRAPHIC: string;
|
|
30
|
-
PERSPECTIVE: string;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* 相机矩阵
|
|
34
|
-
*/
|
|
35
|
-
matrix: mat4;
|
|
36
|
-
/**
|
|
37
|
-
* u 轴
|
|
38
|
-
* @see http://learnwebgl.brown37.net/07_cameras/camera_introduction.html#a-camera-definition
|
|
39
|
-
*/
|
|
40
|
-
right: vec3;
|
|
41
|
-
/**
|
|
42
|
-
* v 轴
|
|
43
|
-
*/
|
|
44
|
-
up: vec3;
|
|
45
|
-
/**
|
|
46
|
-
* n 轴
|
|
47
|
-
*/
|
|
48
|
-
forward: vec3;
|
|
49
|
-
/**
|
|
50
|
-
* 相机位置
|
|
51
|
-
*/
|
|
52
|
-
position: vec3;
|
|
53
|
-
/**
|
|
54
|
-
* 视点位置
|
|
55
|
-
*/
|
|
56
|
-
focalPoint: vec3;
|
|
57
|
-
/**
|
|
58
|
-
* 相机位置到视点向量
|
|
59
|
-
* focalPoint - position
|
|
60
|
-
*/
|
|
61
|
-
distanceVector: vec3;
|
|
62
|
-
/**
|
|
63
|
-
* 相机位置到视点距离
|
|
64
|
-
* length(focalPoint - position)
|
|
65
|
-
*/
|
|
66
|
-
distance: number;
|
|
67
|
-
/**
|
|
68
|
-
* @see https://en.wikipedia.org/wiki/Azimuth
|
|
69
|
-
*/
|
|
70
|
-
azimuth: number;
|
|
71
|
-
elevation: number;
|
|
72
|
-
roll: number;
|
|
73
|
-
relAzimuth: number;
|
|
74
|
-
relElevation: number;
|
|
75
|
-
relRoll: number;
|
|
76
|
-
/**
|
|
77
|
-
* 沿 n 轴移动时,保证移动速度从快到慢
|
|
78
|
-
*/
|
|
79
|
-
dollyingStep: number;
|
|
80
|
-
maxDistance: number;
|
|
81
|
-
minDistance: number;
|
|
82
|
-
/**
|
|
83
|
-
* invert the horizontal coordinate system HCS
|
|
84
|
-
*/
|
|
85
|
-
rotateWorld: boolean;
|
|
86
|
-
interactor: IInteractorService;
|
|
87
|
-
/**
|
|
88
|
-
* 投影矩阵参数
|
|
89
|
-
*/
|
|
90
|
-
/**
|
|
91
|
-
* field of view [0-360]
|
|
92
|
-
* @see http://en.wikipedia.org/wiki/Angle_of_view
|
|
93
|
-
*/
|
|
94
|
-
private fov;
|
|
95
|
-
private near;
|
|
96
|
-
private far;
|
|
97
|
-
private aspect;
|
|
98
|
-
private left;
|
|
99
|
-
private rright;
|
|
100
|
-
private top;
|
|
101
|
-
private bottom;
|
|
102
|
-
private zoom;
|
|
103
|
-
private perspective;
|
|
104
|
-
private view;
|
|
105
|
-
private following;
|
|
106
|
-
private type;
|
|
107
|
-
private trackingMode;
|
|
108
|
-
private projectionMode;
|
|
109
|
-
/**
|
|
110
|
-
* for culling use
|
|
111
|
-
*/
|
|
112
|
-
private frustum;
|
|
113
|
-
/**
|
|
114
|
-
* switch between multiple landmarks
|
|
115
|
-
*/
|
|
116
|
-
private landmarks;
|
|
117
|
-
private landmarkAnimationID;
|
|
118
|
-
clone(): Camera;
|
|
119
|
-
getProjectionMode(): CAMERA_PROJECTION_MODE;
|
|
120
|
-
getPerspective(): mat4;
|
|
121
|
-
getFrustum(): Frustum;
|
|
122
|
-
getPosition(): vec3;
|
|
123
|
-
setType(type: CAMERA_TYPE, trackingMode: CAMERA_TRACKING_MODE | undefined): this;
|
|
124
|
-
setProjectionMode(projectionMode: CAMERA_PROJECTION_MODE): this;
|
|
125
|
-
setTrackingMode(trackingMode: CAMERA_TRACKING_MODE): this;
|
|
126
|
-
/**
|
|
127
|
-
* If flag is true, it reverses the azimuth and elevation angles.
|
|
128
|
-
* Subsequent calls to rotate, setAzimuth, setElevation,
|
|
129
|
-
* changeAzimuth or changeElevation will cause the inverted effect.
|
|
130
|
-
* setRoll or changeRoll is not affected by this method.
|
|
131
|
-
*
|
|
132
|
-
* This inversion is useful when one wants to simulate that the world
|
|
133
|
-
* is moving, instead of the camera.
|
|
134
|
-
*
|
|
135
|
-
* By default the camera angles are not reversed.
|
|
136
|
-
* @param {Boolean} flag the boolean flag to reverse the angles.
|
|
137
|
-
*/
|
|
138
|
-
setWorldRotation(flag: boolean): void;
|
|
139
|
-
/**
|
|
140
|
-
* 计算 MV 矩阵,为相机矩阵的逆矩阵
|
|
141
|
-
*/
|
|
142
|
-
getViewTransform(): mat4;
|
|
143
|
-
getWorldTransform(): mat4;
|
|
144
|
-
/**
|
|
145
|
-
* 设置相机矩阵
|
|
146
|
-
*/
|
|
147
|
-
setMatrix(matrix: mat4): this;
|
|
148
|
-
setAspect(aspect: number): this;
|
|
149
|
-
/**
|
|
150
|
-
* Sets an offset in a larger frustum, used in PixelPicking
|
|
151
|
-
*/
|
|
152
|
-
setViewOffset(fullWidth: number, fullHeight: number, x: number, y: number, width: number, height: number): this;
|
|
153
|
-
clearViewOffset(): this;
|
|
154
|
-
setPerspective(near: number, far: number, fov: number, aspect: number): this;
|
|
155
|
-
setOrthographic(l: number, r: number, t: number, b: number, near: number, far: number): this;
|
|
156
|
-
/**
|
|
157
|
-
* 设置相机位置
|
|
158
|
-
*/
|
|
159
|
-
setPosition(x: number | vec3, y?: number, z?: number): this;
|
|
160
|
-
/**
|
|
161
|
-
* 设置视点位置
|
|
162
|
-
*/
|
|
163
|
-
setFocalPoint(x: number | vec3, y?: number, z?: number): this;
|
|
164
|
-
/**
|
|
165
|
-
* 固定当前视点,按指定距离放置相机
|
|
166
|
-
*/
|
|
167
|
-
setDistance(d: number): this | undefined;
|
|
168
|
-
setMaxDistance(d: number): this;
|
|
169
|
-
setMinDistance(d: number): this;
|
|
170
|
-
/**
|
|
171
|
-
* Changes the initial azimuth of the camera
|
|
172
|
-
*/
|
|
173
|
-
changeAzimuth(az: number): this;
|
|
174
|
-
/**
|
|
175
|
-
* Changes the initial elevation of the camera
|
|
176
|
-
*/
|
|
177
|
-
changeElevation(el: number): this;
|
|
178
|
-
/**
|
|
179
|
-
* Changes the initial roll of the camera
|
|
180
|
-
*/
|
|
181
|
-
changeRoll(rl: number): this;
|
|
182
|
-
/**
|
|
183
|
-
* 设置相机方位角,不同相机模式下需要重新计算相机位置或者是视点位置
|
|
184
|
-
* @param {Number} el the azimuth in degrees
|
|
185
|
-
*/
|
|
186
|
-
setAzimuth(az: number): this;
|
|
187
|
-
getAzimuth(): number;
|
|
188
|
-
/**
|
|
189
|
-
* 设置相机方位角,不同相机模式下需要重新计算相机位置或者是视点位置
|
|
190
|
-
* @param {Number} el the elevation in degrees
|
|
191
|
-
*/
|
|
192
|
-
setElevation(el: number): this;
|
|
193
|
-
/**
|
|
194
|
-
* 设置相机方位角,不同相机模式下需要重新计算相机位置或者是视点位置
|
|
195
|
-
* @param {Number} angle the roll angle
|
|
196
|
-
*/
|
|
197
|
-
setRoll(angle: number): this;
|
|
198
|
-
/**
|
|
199
|
-
* Changes the azimuth and elevation with respect to the current camera axes
|
|
200
|
-
* @param {Number} azimuth the relative azimuth
|
|
201
|
-
* @param {Number} elevation the relative elevation
|
|
202
|
-
* @param {Number} roll the relative roll
|
|
203
|
-
*/
|
|
204
|
-
rotate(azimuth: number, elevation: number, roll: number): this | undefined;
|
|
205
|
-
/**
|
|
206
|
-
* 沿水平(right) & 垂直(up)平移相机
|
|
207
|
-
*/
|
|
208
|
-
pan(tx: number, ty: number): this;
|
|
209
|
-
/**
|
|
210
|
-
* 沿 n 轴移动,当距离视点远时移动速度较快,离视点越近速度越慢
|
|
211
|
-
*/
|
|
212
|
-
dolly(value: number): this;
|
|
213
|
-
createLandmark(name: string, params: {
|
|
214
|
-
position: vec3;
|
|
215
|
-
focalPoint: vec3;
|
|
216
|
-
roll?: number;
|
|
217
|
-
}): Landmark;
|
|
218
|
-
setLandmark(name: string): this;
|
|
219
|
-
gotoLandmark(name: string, duration?: number): void;
|
|
220
|
-
/**
|
|
221
|
-
* 根据相机矩阵重新计算各种相机参数
|
|
222
|
-
*/
|
|
223
|
-
private _update;
|
|
224
|
-
/**
|
|
225
|
-
* 计算相机矩阵
|
|
226
|
-
*/
|
|
227
|
-
private computeMatrix;
|
|
228
|
-
/**
|
|
229
|
-
* Sets the camera position in the camera matrix
|
|
230
|
-
*/
|
|
231
|
-
private _setPosition;
|
|
232
|
-
/**
|
|
233
|
-
* Recalculates axes based on the current matrix
|
|
234
|
-
*/
|
|
235
|
-
private _getAxes;
|
|
236
|
-
/**
|
|
237
|
-
* Recalculates euler angles based on the current state
|
|
238
|
-
*/
|
|
239
|
-
private _getAngles;
|
|
240
|
-
/**
|
|
241
|
-
* 重新计算相机位置,只有 ORBITING 模式相机位置才会发生变化
|
|
242
|
-
*/
|
|
243
|
-
private _getPosition;
|
|
244
|
-
/**
|
|
245
|
-
* 重新计算视点,只有 TRACKING 模式视点才会发生变化
|
|
246
|
-
*/
|
|
247
|
-
private _getFocalPoint;
|
|
248
|
-
/**
|
|
249
|
-
* 重新计算视距
|
|
250
|
-
*/
|
|
251
|
-
private _getDistance;
|
|
252
|
-
}
|