@ridp/threejs 0.2.0 → 1.1.0
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/dist/ImageLoader-CB_URfeZ.js +860 -0
- package/dist/ImageLoader-DwvBWW6h.cjs +5 -0
- package/dist/common-BHi3qsZW.cjs +15 -0
- package/dist/{common-DESmndxO.js → common-fbJUHqlj.js} +1 -1
- package/dist/hooks.cjs +1 -1
- package/dist/hooks.js +7 -9
- package/dist/threejs.cjs +1 -1
- package/dist/threejs.js +17 -15
- package/dist/useGLTFLoader-DHxBLucO.js +5629 -0
- package/dist/useGLTFLoader-DM3-7jdq.cjs +4 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +15 -12
- package/esdoc/ast/source/.external-ecmascript.js.json +2802 -0
- package/esdoc/ast/source/hooks/index.js.json +739 -0
- package/esdoc/ast/source/hooks/useGLTFLoader.js.json +9111 -0
- package/esdoc/ast/source/hooks/useObb.js.json +16463 -0
- package/esdoc/ast/source/hooks/useRaycaster.js.json +15556 -0
- package/esdoc/ast/source/hooks/useThreeJs.js.json +52887 -0
- package/esdoc/ast/source/index.js.json +570 -0
- package/esdoc/ast/source/instance/IDBCache.js.json +40978 -0
- package/esdoc/ast/source/instance/index.js.json +232 -0
- package/esdoc/ast/source/utils/ImageLoader.js.json +7037 -0
- package/esdoc/ast/source/utils/common.js.json +5134 -0
- package/esdoc/ast/source/utils/css3dHelper.js.json +9101 -0
- package/esdoc/ast/source/utils/disposeObject.js.json +5978 -0
- package/esdoc/ast/source/utils/helper.js.json +10522 -0
- package/esdoc/ast/source/utils/index.js.json +908 -0
- package/esdoc/badge.svg +17 -0
- package/esdoc/class/src/instance/IDBCache.js~IDBCache.html +1299 -0
- package/esdoc/coverage.json +86 -0
- package/esdoc/css/github.css +83 -0
- package/esdoc/css/identifiers.css +37 -0
- package/esdoc/css/manual.css +134 -0
- package/esdoc/css/prettify-tomorrow.css +132 -0
- package/esdoc/css/search.css +84 -0
- package/esdoc/css/source.css +55 -0
- package/esdoc/css/style.css +608 -0
- package/esdoc/css/test.css +58 -0
- package/esdoc/file/src/hooks/index.js.html +79 -0
- package/esdoc/file/src/hooks/useGLTFLoader.js.html +146 -0
- package/esdoc/file/src/hooks/useObb.js.html +149 -0
- package/esdoc/file/src/hooks/useRaycaster.js.html +153 -0
- package/esdoc/file/src/hooks/useThreeJs.js.html +362 -0
- package/esdoc/file/src/index.js.html +78 -0
- package/esdoc/file/src/instance/IDBCache.js.html +312 -0
- package/esdoc/file/src/instance/index.js.html +76 -0
- package/esdoc/file/src/utils/ImageLoader.js.html +118 -0
- package/esdoc/file/src/utils/common.js.html +102 -0
- package/esdoc/file/src/utils/css3dHelper.js.html +131 -0
- package/esdoc/file/src/utils/disposeObject.js.html +114 -0
- package/esdoc/file/src/utils/helper.js.html +138 -0
- package/esdoc/file/src/utils/index.js.html +80 -0
- package/esdoc/function/index.html +2019 -0
- package/esdoc/identifiers.html +738 -0
- package/esdoc/image/badge.svg +17 -0
- package/esdoc/image/esdoc-logo-mini-black.png +0 -0
- package/esdoc/image/esdoc-logo-mini.png +0 -0
- package/esdoc/image/manual-badge.svg +17 -0
- package/esdoc/image/search.png +0 -0
- package/esdoc/index.html +153 -0
- package/esdoc/index.json +2051 -0
- package/esdoc/inject/css/0-cus-style.css +1 -0
- package/esdoc/lint.json +1 -0
- package/esdoc/script/inherited-summary.js +28 -0
- package/esdoc/script/inner-link.js +32 -0
- package/esdoc/script/manual.js +12 -0
- package/esdoc/script/patch-for-local.js +8 -0
- package/esdoc/script/prettify/Apache-License-2.0.txt +202 -0
- package/esdoc/script/prettify/prettify.js +46 -0
- package/esdoc/script/pretty-print.js +25 -0
- package/esdoc/script/search.js +117 -0
- package/esdoc/script/search_index.js +572 -0
- package/esdoc/script/test-summary.js +54 -0
- package/esdoc/source.html +213 -0
- package/esdoc/variable/index.html +225 -0
- package/package.json +13 -3
- package/readme.md +93 -0
- package/dist/common-nMt4tIRA.cjs +0 -15
- package/dist/disposeObject-BuI3II7v.cjs +0 -1
- package/dist/disposeObject-CmFSSgi7.js +0 -616
- package/dist/useGLTFLoader-BAoIZjEX.js +0 -2645
- package/dist/useGLTFLoader-CGOxhEOO.cjs +0 -6
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<base data-ice="baseUrl" href="../../../">
|
|
6
|
+
<title data-ice="title">src/instance/IDBCache.js | @ridp/threejs</title>
|
|
7
|
+
<link type="text/css" rel="stylesheet" href="css/style.css">
|
|
8
|
+
<link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
|
|
9
|
+
<script src="script/prettify/prettify.js"></script>
|
|
10
|
+
<script src="script/manual.js"></script>
|
|
11
|
+
<link rel="stylesheet" href="./inject/css/0-cus-style.css"></head>
|
|
12
|
+
<body class="layout-container" data-ice="rootContainer">
|
|
13
|
+
|
|
14
|
+
<header>
|
|
15
|
+
<a href="./">Home</a>
|
|
16
|
+
|
|
17
|
+
<a href="identifiers.html">Reference</a>
|
|
18
|
+
<a href="source.html">Source</a>
|
|
19
|
+
|
|
20
|
+
<div class="search-box">
|
|
21
|
+
<span>
|
|
22
|
+
<img src="./image/search.png">
|
|
23
|
+
<span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
|
|
24
|
+
</span>
|
|
25
|
+
<ul class="search-result"></ul>
|
|
26
|
+
</div>
|
|
27
|
+
</header>
|
|
28
|
+
|
|
29
|
+
<nav class="navigation" data-ice="nav"><div>
|
|
30
|
+
<ul>
|
|
31
|
+
|
|
32
|
+
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#hooks">hooks</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useGLTFLoader">useGLTFLoader</a></span></span></li>
|
|
33
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useObb">useObb</a></span></span></li>
|
|
34
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useRaycaster">useRaycaster</a></span></span></li>
|
|
35
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useThreeJs">useThreeJs</a></span></span></li>
|
|
36
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-intersectColor">intersectColor</a></span></span></li>
|
|
37
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-obbObjects">obbObjects</a></span></span></li>
|
|
38
|
+
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#instance">instance</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/instance/IDBCache.js~IDBCache.html">IDBCache</a></span></span></li>
|
|
39
|
+
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#utils">utils</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-ImageLoader">ImageLoader</a></span></span></li>
|
|
40
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-initEnvImage">initEnvImage</a></span></span></li>
|
|
41
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-getCommonParent">getCommonParent</a></span></span></li>
|
|
42
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createInfoPlane">createInfoPlane</a></span></span></li>
|
|
43
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createTagPlane">createTagPlane</a></span></span></li>
|
|
44
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-disposeThreeObject">disposeThreeObject</a></span></span></li>
|
|
45
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createArrowHelper">createArrowHelper</a></span></span></li>
|
|
46
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createAxesHelper">createAxesHelper</a></span></span></li>
|
|
47
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createBox3Helper">createBox3Helper</a></span></span></li>
|
|
48
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createCameraHelper">createCameraHelper</a></span></span></li>
|
|
49
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createGridHelper">createGridHelper</a></span></span></li>
|
|
50
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createMapControls">createMapControls</a></span></span></li>
|
|
51
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createOrbitControl">createOrbitControl</a></span></span></li>
|
|
52
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createRaycaster">createRaycaster</a></span></span></li>
|
|
53
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createStats">createStats</a></span></span></li>
|
|
54
|
+
</ul>
|
|
55
|
+
</div>
|
|
56
|
+
</nav>
|
|
57
|
+
|
|
58
|
+
<div class="content" data-ice="content"><h1 data-ice="title">src/instance/IDBCache.js</h1>
|
|
59
|
+
<pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">import * as THREE from "three";
|
|
60
|
+
import Dexie from "dexie";
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* ThreeJS 缓存工具类
|
|
64
|
+
*/
|
|
65
|
+
export class IDBCache {
|
|
66
|
+
/**
|
|
67
|
+
* 构造函数
|
|
68
|
+
* @param {string} dbName - 数据库名称
|
|
69
|
+
* @param {Object} tableDefinitions - 表定义对象,例如 { models: "&path, data" }
|
|
70
|
+
* @param {number} version - 数据库版本号
|
|
71
|
+
*/
|
|
72
|
+
constructor(dbName = "threeJsIDBCache", version = 1) {
|
|
73
|
+
this.db = new Dexie(dbName);
|
|
74
|
+
this.materialMap = {};
|
|
75
|
+
|
|
76
|
+
// 初始化数据库版本和表
|
|
77
|
+
this.db.version(version).stores({ models: "&path, data" });
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 获取 Dexie 数据库实例
|
|
82
|
+
* @returns {Dexie} Dexie 实例
|
|
83
|
+
*/
|
|
84
|
+
getDatabase() {
|
|
85
|
+
return this.db;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 序列化 Three.js 对象
|
|
90
|
+
* @param {THREE.Object3D} object - 要序列化的对象
|
|
91
|
+
* @returns {Object} 序列化后的数据
|
|
92
|
+
*/
|
|
93
|
+
serObject3D(object) {
|
|
94
|
+
const serialized = {
|
|
95
|
+
type: object.type,
|
|
96
|
+
name: object.name,
|
|
97
|
+
position: object.position.toArray(),
|
|
98
|
+
rotation: object.rotation.toArray(),
|
|
99
|
+
scale: object.scale.toArray(),
|
|
100
|
+
visible: object.visible,
|
|
101
|
+
children: [],
|
|
102
|
+
geometry: null,
|
|
103
|
+
material: null,
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
if (object.isMesh) {
|
|
107
|
+
serialized.geometry = this.serGeometry(object.geometry);
|
|
108
|
+
serialized.material = this.serMaterial(object.material);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
for (const child of object.children) {
|
|
112
|
+
serialized.children.push(this.serObject3D(child));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return serialized;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* 序列化几何体
|
|
120
|
+
* @param {THREE.BufferGeometry} geometry - 几何体
|
|
121
|
+
* @returns {Object} 序列化后的几何体数据
|
|
122
|
+
*/
|
|
123
|
+
serGeometry(geometry) {
|
|
124
|
+
const _attributes = [];
|
|
125
|
+
const { attributes, index, type } = geometry;
|
|
126
|
+
|
|
127
|
+
if (attributes.position)
|
|
128
|
+
_attributes["position"] = {
|
|
129
|
+
type: "Float32Array",
|
|
130
|
+
array: Array.from(attributes.position.array),
|
|
131
|
+
itemSize: 3,
|
|
132
|
+
};
|
|
133
|
+
if (attributes.normal)
|
|
134
|
+
_attributes["normal"] = {
|
|
135
|
+
type: "Float32Array",
|
|
136
|
+
array: Array.from(attributes.normal.array),
|
|
137
|
+
itemSize: 3,
|
|
138
|
+
};
|
|
139
|
+
if (attributes.uv)
|
|
140
|
+
_attributes["uv"] = {
|
|
141
|
+
type: "Float32Array",
|
|
142
|
+
array: Array.from(attributes.uv.array),
|
|
143
|
+
itemSize: 2,
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const result = {
|
|
147
|
+
type: type,
|
|
148
|
+
attributes: _attributes,
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
if (index && index.array) {
|
|
152
|
+
result["index"] = {
|
|
153
|
+
type: "Uint32Array",
|
|
154
|
+
array: Array.from(index.array),
|
|
155
|
+
itemSize: 1,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return result;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* 反序列化几何体
|
|
164
|
+
* @param {Object} data - 序列化后的几何体数据
|
|
165
|
+
* @returns {THREE.BufferGeometry} 反序列化后的几何体
|
|
166
|
+
*/
|
|
167
|
+
reSerGeometry(data) {
|
|
168
|
+
const { type, attributes, index } = data;
|
|
169
|
+
const geometry = new THREE.BufferGeometry();
|
|
170
|
+
Object.keys(attributes).forEach((key) => {
|
|
171
|
+
const { type, array, itemSize } = attributes[key];
|
|
172
|
+
geometry.setAttribute(
|
|
173
|
+
key,
|
|
174
|
+
new THREE.BufferAttribute(new Float32Array(array), itemSize)
|
|
175
|
+
);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
if (index) {
|
|
179
|
+
geometry.setIndex(index.array);
|
|
180
|
+
}
|
|
181
|
+
return geometry;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* 序列化材质
|
|
186
|
+
* @param {THREE.Material} material - 材质
|
|
187
|
+
* @returns {Object} 序列化后的材质数据
|
|
188
|
+
*/
|
|
189
|
+
serMaterial(material) {
|
|
190
|
+
return {
|
|
191
|
+
type: material.type,
|
|
192
|
+
color: material.color.getHex(),
|
|
193
|
+
map: material.map ? material.map.image.src : null,
|
|
194
|
+
opacity: material.opacity,
|
|
195
|
+
name: material.name,
|
|
196
|
+
depthTest: material.depthTest,
|
|
197
|
+
depthWrite: material.depthWrite,
|
|
198
|
+
transparent: material.transparent,
|
|
199
|
+
side: material.side,
|
|
200
|
+
roughness: material.roughness,
|
|
201
|
+
metalness: material.metalness,
|
|
202
|
+
emissive: material.emissive.getHex(),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* 反序列化材质
|
|
208
|
+
* @param {Object} data - 序列化后的材质数据
|
|
209
|
+
* @returns {THREE.Material} 反序列化后的材质
|
|
210
|
+
*/
|
|
211
|
+
reSerMaterial(data) {
|
|
212
|
+
// 同名材质复用
|
|
213
|
+
if (this.materialMap[data.name]) return this.materialMap[data.name];
|
|
214
|
+
const { type, ...rest } = data;
|
|
215
|
+
|
|
216
|
+
const materialType = type || "MeshStandardMaterial";
|
|
217
|
+
const material = new THREE[materialType]({ ...rest });
|
|
218
|
+
if (data.map) {
|
|
219
|
+
const texture = new THREE.TextureLoader().load(data.map);
|
|
220
|
+
material.map = texture;
|
|
221
|
+
}
|
|
222
|
+
material.needsUpdate = true;
|
|
223
|
+
|
|
224
|
+
this.materialMap[data.name] = material;
|
|
225
|
+
return material;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* 反序列化 Three.js 对象
|
|
230
|
+
* @param {Object} data - 序列化后的数据
|
|
231
|
+
* @returns {THREE.Object3D} 反序列化后的对象
|
|
232
|
+
*/
|
|
233
|
+
reSerObject3D(data) {
|
|
234
|
+
let object;
|
|
235
|
+
|
|
236
|
+
switch (data.type) {
|
|
237
|
+
case "Mesh":
|
|
238
|
+
const geometry = this.reSerGeometry(data.geometry);
|
|
239
|
+
const material = this.reSerMaterial(data.material);
|
|
240
|
+
object = new THREE.Mesh(geometry, material);
|
|
241
|
+
break;
|
|
242
|
+
case "Group":
|
|
243
|
+
object = new THREE.Group();
|
|
244
|
+
break;
|
|
245
|
+
case "Object3D":
|
|
246
|
+
object = new THREE.Object3D();
|
|
247
|
+
break;
|
|
248
|
+
default:
|
|
249
|
+
console.warn(`Unsupported object type: ${data.type}`);
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
object.name = data.name;
|
|
254
|
+
object.position.fromArray(data.position);
|
|
255
|
+
object.rotation.fromArray(data.rotation);
|
|
256
|
+
object.scale.fromArray(data.scale);
|
|
257
|
+
object.visible = data.visible;
|
|
258
|
+
|
|
259
|
+
for (const childData of data.children) {
|
|
260
|
+
const child = this.reSerObject3D(childData);
|
|
261
|
+
if (child) {
|
|
262
|
+
object.add(child);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return object;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* 缓存模型到 IndexedDB
|
|
271
|
+
* @param {string} path - 主键值
|
|
272
|
+
* @param {THREE.Object3D} model - 要缓存的模型
|
|
273
|
+
*/
|
|
274
|
+
async cacheModel(path, model) {
|
|
275
|
+
const serializedData = this.serObject3D(model);
|
|
276
|
+
await this.db.table("models").put({ path, data: serializedData });
|
|
277
|
+
console.log(`Model "${path}" cached successfully in table models`);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* 从 IndexedDB 加载缓存的模型
|
|
282
|
+
* @param {string} path - 主键值
|
|
283
|
+
* @returns {THREE.Object3D | null} 加载的模型
|
|
284
|
+
*/
|
|
285
|
+
async loadCachedModel(path) {
|
|
286
|
+
const record = await this.db.table("models").get(path);
|
|
287
|
+
if (!record) {
|
|
288
|
+
console.warn(`Model "${path}" not found in table models`);
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
const deserializedModel = this.reSerObject3D(record.data);
|
|
292
|
+
console.log(`Model "${path}" loaded from table models`);
|
|
293
|
+
return deserializedModel;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
</code></pre>
|
|
297
|
+
|
|
298
|
+
</div>
|
|
299
|
+
|
|
300
|
+
<footer class="footer">
|
|
301
|
+
Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(1.1.0)</span><img src="./image/esdoc-logo-mini-black.png"></a>
|
|
302
|
+
</footer>
|
|
303
|
+
|
|
304
|
+
<script src="script/search_index.js"></script>
|
|
305
|
+
<script src="script/search.js"></script>
|
|
306
|
+
<script src="script/pretty-print.js"></script>
|
|
307
|
+
<script src="script/inherited-summary.js"></script>
|
|
308
|
+
<script src="script/test-summary.js"></script>
|
|
309
|
+
<script src="script/inner-link.js"></script>
|
|
310
|
+
<script src="script/patch-for-local.js"></script>
|
|
311
|
+
</body>
|
|
312
|
+
</html>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<base data-ice="baseUrl" href="../../../">
|
|
6
|
+
<title data-ice="title">src/instance/index.js | @ridp/threejs</title>
|
|
7
|
+
<link type="text/css" rel="stylesheet" href="css/style.css">
|
|
8
|
+
<link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
|
|
9
|
+
<script src="script/prettify/prettify.js"></script>
|
|
10
|
+
<script src="script/manual.js"></script>
|
|
11
|
+
<link rel="stylesheet" href="./inject/css/0-cus-style.css"></head>
|
|
12
|
+
<body class="layout-container" data-ice="rootContainer">
|
|
13
|
+
|
|
14
|
+
<header>
|
|
15
|
+
<a href="./">Home</a>
|
|
16
|
+
|
|
17
|
+
<a href="identifiers.html">Reference</a>
|
|
18
|
+
<a href="source.html">Source</a>
|
|
19
|
+
|
|
20
|
+
<div class="search-box">
|
|
21
|
+
<span>
|
|
22
|
+
<img src="./image/search.png">
|
|
23
|
+
<span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
|
|
24
|
+
</span>
|
|
25
|
+
<ul class="search-result"></ul>
|
|
26
|
+
</div>
|
|
27
|
+
</header>
|
|
28
|
+
|
|
29
|
+
<nav class="navigation" data-ice="nav"><div>
|
|
30
|
+
<ul>
|
|
31
|
+
|
|
32
|
+
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#hooks">hooks</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useGLTFLoader">useGLTFLoader</a></span></span></li>
|
|
33
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useObb">useObb</a></span></span></li>
|
|
34
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useRaycaster">useRaycaster</a></span></span></li>
|
|
35
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useThreeJs">useThreeJs</a></span></span></li>
|
|
36
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-intersectColor">intersectColor</a></span></span></li>
|
|
37
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-obbObjects">obbObjects</a></span></span></li>
|
|
38
|
+
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#instance">instance</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/instance/IDBCache.js~IDBCache.html">IDBCache</a></span></span></li>
|
|
39
|
+
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#utils">utils</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-ImageLoader">ImageLoader</a></span></span></li>
|
|
40
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-initEnvImage">initEnvImage</a></span></span></li>
|
|
41
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-getCommonParent">getCommonParent</a></span></span></li>
|
|
42
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createInfoPlane">createInfoPlane</a></span></span></li>
|
|
43
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createTagPlane">createTagPlane</a></span></span></li>
|
|
44
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-disposeThreeObject">disposeThreeObject</a></span></span></li>
|
|
45
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createArrowHelper">createArrowHelper</a></span></span></li>
|
|
46
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createAxesHelper">createAxesHelper</a></span></span></li>
|
|
47
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createBox3Helper">createBox3Helper</a></span></span></li>
|
|
48
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createCameraHelper">createCameraHelper</a></span></span></li>
|
|
49
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createGridHelper">createGridHelper</a></span></span></li>
|
|
50
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createMapControls">createMapControls</a></span></span></li>
|
|
51
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createOrbitControl">createOrbitControl</a></span></span></li>
|
|
52
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createRaycaster">createRaycaster</a></span></span></li>
|
|
53
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createStats">createStats</a></span></span></li>
|
|
54
|
+
</ul>
|
|
55
|
+
</div>
|
|
56
|
+
</nav>
|
|
57
|
+
|
|
58
|
+
<div class="content" data-ice="content"><h1 data-ice="title">src/instance/index.js</h1>
|
|
59
|
+
<pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">export * from "./IDBCache";
|
|
60
|
+
</code></pre>
|
|
61
|
+
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<footer class="footer">
|
|
65
|
+
Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(1.1.0)</span><img src="./image/esdoc-logo-mini-black.png"></a>
|
|
66
|
+
</footer>
|
|
67
|
+
|
|
68
|
+
<script src="script/search_index.js"></script>
|
|
69
|
+
<script src="script/search.js"></script>
|
|
70
|
+
<script src="script/pretty-print.js"></script>
|
|
71
|
+
<script src="script/inherited-summary.js"></script>
|
|
72
|
+
<script src="script/test-summary.js"></script>
|
|
73
|
+
<script src="script/inner-link.js"></script>
|
|
74
|
+
<script src="script/patch-for-local.js"></script>
|
|
75
|
+
</body>
|
|
76
|
+
</html>
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<base data-ice="baseUrl" href="../../../">
|
|
6
|
+
<title data-ice="title">src/utils/ImageLoader.js | @ridp/threejs</title>
|
|
7
|
+
<link type="text/css" rel="stylesheet" href="css/style.css">
|
|
8
|
+
<link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
|
|
9
|
+
<script src="script/prettify/prettify.js"></script>
|
|
10
|
+
<script src="script/manual.js"></script>
|
|
11
|
+
<link rel="stylesheet" href="./inject/css/0-cus-style.css"></head>
|
|
12
|
+
<body class="layout-container" data-ice="rootContainer">
|
|
13
|
+
|
|
14
|
+
<header>
|
|
15
|
+
<a href="./">Home</a>
|
|
16
|
+
|
|
17
|
+
<a href="identifiers.html">Reference</a>
|
|
18
|
+
<a href="source.html">Source</a>
|
|
19
|
+
|
|
20
|
+
<div class="search-box">
|
|
21
|
+
<span>
|
|
22
|
+
<img src="./image/search.png">
|
|
23
|
+
<span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
|
|
24
|
+
</span>
|
|
25
|
+
<ul class="search-result"></ul>
|
|
26
|
+
</div>
|
|
27
|
+
</header>
|
|
28
|
+
|
|
29
|
+
<nav class="navigation" data-ice="nav"><div>
|
|
30
|
+
<ul>
|
|
31
|
+
|
|
32
|
+
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#hooks">hooks</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useGLTFLoader">useGLTFLoader</a></span></span></li>
|
|
33
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useObb">useObb</a></span></span></li>
|
|
34
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useRaycaster">useRaycaster</a></span></span></li>
|
|
35
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useThreeJs">useThreeJs</a></span></span></li>
|
|
36
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-intersectColor">intersectColor</a></span></span></li>
|
|
37
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-obbObjects">obbObjects</a></span></span></li>
|
|
38
|
+
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#instance">instance</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/instance/IDBCache.js~IDBCache.html">IDBCache</a></span></span></li>
|
|
39
|
+
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#utils">utils</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-ImageLoader">ImageLoader</a></span></span></li>
|
|
40
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-initEnvImage">initEnvImage</a></span></span></li>
|
|
41
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-getCommonParent">getCommonParent</a></span></span></li>
|
|
42
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createInfoPlane">createInfoPlane</a></span></span></li>
|
|
43
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createTagPlane">createTagPlane</a></span></span></li>
|
|
44
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-disposeThreeObject">disposeThreeObject</a></span></span></li>
|
|
45
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createArrowHelper">createArrowHelper</a></span></span></li>
|
|
46
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createAxesHelper">createAxesHelper</a></span></span></li>
|
|
47
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createBox3Helper">createBox3Helper</a></span></span></li>
|
|
48
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createCameraHelper">createCameraHelper</a></span></span></li>
|
|
49
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createGridHelper">createGridHelper</a></span></span></li>
|
|
50
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createMapControls">createMapControls</a></span></span></li>
|
|
51
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createOrbitControl">createOrbitControl</a></span></span></li>
|
|
52
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createRaycaster">createRaycaster</a></span></span></li>
|
|
53
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createStats">createStats</a></span></span></li>
|
|
54
|
+
</ul>
|
|
55
|
+
</div>
|
|
56
|
+
</nav>
|
|
57
|
+
|
|
58
|
+
<div class="content" data-ice="content"><h1 data-ice="title">src/utils/ImageLoader.js</h1>
|
|
59
|
+
<pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">import { RGBELoader } from "three/examples/jsm/Addons.js";
|
|
60
|
+
import { EquirectangularReflectionMapping } from "three";
|
|
61
|
+
|
|
62
|
+
const cacheHdr = {};
|
|
63
|
+
|
|
64
|
+
const rgbeLoader = new RGBELoader();
|
|
65
|
+
/**
|
|
66
|
+
* 环境贴图加载 && 缓存 && 设置到 scene
|
|
67
|
+
* @param { THREE.Scene } scene threejs 场景对象
|
|
68
|
+
* @param { String } path 图片地址
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
export async function initEnvImage(scene, path) {
|
|
72
|
+
if (!path) return;
|
|
73
|
+
if (cacheHdr[path]) {
|
|
74
|
+
const texture = cacheHdr[path];
|
|
75
|
+
scene.environment = texture;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return new Promise((resolve, reject) => {
|
|
80
|
+
rgbeLoader.load(path, resolve, undefined, reject);
|
|
81
|
+
})
|
|
82
|
+
.then((texture) => {
|
|
83
|
+
texture.mapping = EquirectangularReflectionMapping;
|
|
84
|
+
scene.environment = texture;
|
|
85
|
+
cacheHdr[path] = texture;
|
|
86
|
+
})
|
|
87
|
+
.catch((e) => {
|
|
88
|
+
console.log(" =====> e:", e);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 图片纹理加载
|
|
94
|
+
* @param {*} path 图片路径
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
97
|
+
export async function ImageLoader(path) {
|
|
98
|
+
return new Promise((resolve, reject) => {
|
|
99
|
+
rgbeLoader.load(path, resolve, undefined, reject);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
</code></pre>
|
|
103
|
+
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
<footer class="footer">
|
|
107
|
+
Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(1.1.0)</span><img src="./image/esdoc-logo-mini-black.png"></a>
|
|
108
|
+
</footer>
|
|
109
|
+
|
|
110
|
+
<script src="script/search_index.js"></script>
|
|
111
|
+
<script src="script/search.js"></script>
|
|
112
|
+
<script src="script/pretty-print.js"></script>
|
|
113
|
+
<script src="script/inherited-summary.js"></script>
|
|
114
|
+
<script src="script/test-summary.js"></script>
|
|
115
|
+
<script src="script/inner-link.js"></script>
|
|
116
|
+
<script src="script/patch-for-local.js"></script>
|
|
117
|
+
</body>
|
|
118
|
+
</html>
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<base data-ice="baseUrl" href="../../../">
|
|
6
|
+
<title data-ice="title">src/utils/common.js | @ridp/threejs</title>
|
|
7
|
+
<link type="text/css" rel="stylesheet" href="css/style.css">
|
|
8
|
+
<link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
|
|
9
|
+
<script src="script/prettify/prettify.js"></script>
|
|
10
|
+
<script src="script/manual.js"></script>
|
|
11
|
+
<link rel="stylesheet" href="./inject/css/0-cus-style.css"></head>
|
|
12
|
+
<body class="layout-container" data-ice="rootContainer">
|
|
13
|
+
|
|
14
|
+
<header>
|
|
15
|
+
<a href="./">Home</a>
|
|
16
|
+
|
|
17
|
+
<a href="identifiers.html">Reference</a>
|
|
18
|
+
<a href="source.html">Source</a>
|
|
19
|
+
|
|
20
|
+
<div class="search-box">
|
|
21
|
+
<span>
|
|
22
|
+
<img src="./image/search.png">
|
|
23
|
+
<span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
|
|
24
|
+
</span>
|
|
25
|
+
<ul class="search-result"></ul>
|
|
26
|
+
</div>
|
|
27
|
+
</header>
|
|
28
|
+
|
|
29
|
+
<nav class="navigation" data-ice="nav"><div>
|
|
30
|
+
<ul>
|
|
31
|
+
|
|
32
|
+
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#hooks">hooks</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useGLTFLoader">useGLTFLoader</a></span></span></li>
|
|
33
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useObb">useObb</a></span></span></li>
|
|
34
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useRaycaster">useRaycaster</a></span></span></li>
|
|
35
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useThreeJs">useThreeJs</a></span></span></li>
|
|
36
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-intersectColor">intersectColor</a></span></span></li>
|
|
37
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-obbObjects">obbObjects</a></span></span></li>
|
|
38
|
+
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#instance">instance</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/instance/IDBCache.js~IDBCache.html">IDBCache</a></span></span></li>
|
|
39
|
+
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#utils">utils</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-ImageLoader">ImageLoader</a></span></span></li>
|
|
40
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-initEnvImage">initEnvImage</a></span></span></li>
|
|
41
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-getCommonParent">getCommonParent</a></span></span></li>
|
|
42
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createInfoPlane">createInfoPlane</a></span></span></li>
|
|
43
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createTagPlane">createTagPlane</a></span></span></li>
|
|
44
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-disposeThreeObject">disposeThreeObject</a></span></span></li>
|
|
45
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createArrowHelper">createArrowHelper</a></span></span></li>
|
|
46
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createAxesHelper">createAxesHelper</a></span></span></li>
|
|
47
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createBox3Helper">createBox3Helper</a></span></span></li>
|
|
48
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createCameraHelper">createCameraHelper</a></span></span></li>
|
|
49
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createGridHelper">createGridHelper</a></span></span></li>
|
|
50
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createMapControls">createMapControls</a></span></span></li>
|
|
51
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createOrbitControl">createOrbitControl</a></span></span></li>
|
|
52
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createRaycaster">createRaycaster</a></span></span></li>
|
|
53
|
+
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createStats">createStats</a></span></span></li>
|
|
54
|
+
</ul>
|
|
55
|
+
</div>
|
|
56
|
+
</nav>
|
|
57
|
+
|
|
58
|
+
<div class="content" data-ice="content"><h1 data-ice="title">src/utils/common.js</h1>
|
|
59
|
+
<pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">export const getCommonParent = (meshList, objectGroup) => {
|
|
60
|
+
const parentCount = {};
|
|
61
|
+
|
|
62
|
+
meshList.forEach((mesh) => {
|
|
63
|
+
let parent = mesh.parent;
|
|
64
|
+
while (parent) {
|
|
65
|
+
if (parentCount[parent.uuid]) {
|
|
66
|
+
parentCount[parent.uuid]++;
|
|
67
|
+
} else {
|
|
68
|
+
parentCount[parent.uuid] = 1;
|
|
69
|
+
}
|
|
70
|
+
parent = parent.parent;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
let commonParent = null;
|
|
75
|
+
let maxCount = 0;
|
|
76
|
+
|
|
77
|
+
for (const uuid in parentCount) {
|
|
78
|
+
if (parentCount[uuid] > maxCount) {
|
|
79
|
+
maxCount = parentCount[uuid];
|
|
80
|
+
commonParent = objectGroup.getObjectByProperty("uuid", uuid);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return commonParent;
|
|
85
|
+
};
|
|
86
|
+
</code></pre>
|
|
87
|
+
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<footer class="footer">
|
|
91
|
+
Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(1.1.0)</span><img src="./image/esdoc-logo-mini-black.png"></a>
|
|
92
|
+
</footer>
|
|
93
|
+
|
|
94
|
+
<script src="script/search_index.js"></script>
|
|
95
|
+
<script src="script/search.js"></script>
|
|
96
|
+
<script src="script/pretty-print.js"></script>
|
|
97
|
+
<script src="script/inherited-summary.js"></script>
|
|
98
|
+
<script src="script/test-summary.js"></script>
|
|
99
|
+
<script src="script/inner-link.js"></script>
|
|
100
|
+
<script src="script/patch-for-local.js"></script>
|
|
101
|
+
</body>
|
|
102
|
+
</html>
|