three-base 1.0.21 → 1.0.23
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/README.md +2 -1
- package/lib/InstancedGroupMesh.ts +18 -9
- package/package.json +2 -3
- package/lib/draco/README.md +0 -32
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
1
|
```tsx
|
|
3
2
|
1.创建一个 homeRender.ts 模块
|
|
4
3
|
import { AmbientLight, BoxGeometry, Mesh, MeshLambertMaterial, PointLight } from "three";
|
|
5
4
|
import ThreeBase, { Transition } from "three-base";
|
|
5
|
+
|
|
6
|
+
// 做项目找我 qq:389652405
|
|
6
7
|
class HomeRender extends ThreeBase {
|
|
7
8
|
|
|
8
9
|
constructor() {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: xiaosihan
|
|
3
3
|
* @Date: 2023-02-21 09:55:52
|
|
4
4
|
* @Last Modified by: xiaosihan
|
|
5
|
-
* @Last Modified time: 2023-02-
|
|
5
|
+
* @Last Modified time: 2023-02-26 14:42:21
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import * as THREE from 'three'
|
|
@@ -26,22 +26,31 @@ export default class InstancedGroupMesh extends THREE.Mesh {
|
|
|
26
26
|
|
|
27
27
|
const { meshCollect, instanceCollect } = this
|
|
28
28
|
|
|
29
|
+
group.updateMatrixWorld(true);
|
|
30
|
+
|
|
29
31
|
// collect all mesh counts, in case there are more than one copy of the same mesh in this group
|
|
30
32
|
group.traverse((obj) => {
|
|
31
|
-
if (obj.type !== 'Mesh') return
|
|
32
33
|
const mesh = obj as THREE.Mesh
|
|
34
|
+
if (mesh.isMesh) {
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
mesh.matrixWorld.decompose(mesh.position, mesh.quaternion, mesh.scale);
|
|
37
|
+
mesh.rotation.setFromQuaternion(mesh.quaternion);
|
|
38
|
+
mesh.updateMatrix();
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
// same geometry and same material consider as the same mesh
|
|
41
|
+
const uuid = mesh.geometry.uuid + '/' + (mesh.material as THREE.Material).uuid
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
if (meshCollect[uuid]) {
|
|
44
|
+
meshCollect[uuid].push(mesh)
|
|
45
|
+
} else {
|
|
46
|
+
meshCollect[uuid] = [mesh]
|
|
47
|
+
}
|
|
42
48
|
} else {
|
|
43
|
-
|
|
49
|
+
obj.position.set(0, 0, 0);
|
|
50
|
+
obj.scale.set(1, 1, 1);
|
|
51
|
+
obj.rotation.set(0, 0, 0);
|
|
44
52
|
}
|
|
53
|
+
|
|
45
54
|
})
|
|
46
55
|
|
|
47
56
|
// create all instances
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "three-base",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"description": "three 3d three-base",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"three",
|
|
7
7
|
"3d",
|
|
8
|
-
"three-base"
|
|
9
|
-
"做项目找我 qq:389652405"
|
|
8
|
+
"three-base"
|
|
10
9
|
],
|
|
11
10
|
"main": "index.ts",
|
|
12
11
|
"module": "index.ts",
|
package/lib/draco/README.md
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# Draco 3D Data Compression
|
|
2
|
-
|
|
3
|
-
Draco is an open-source library for compressing and decompressing 3D geometric meshes and point clouds. It is intended to improve the storage and transmission of 3D graphics.
|
|
4
|
-
|
|
5
|
-
[Website](https://google.github.io/draco/) | [GitHub](https://github.com/google/draco)
|
|
6
|
-
|
|
7
|
-
## Contents
|
|
8
|
-
|
|
9
|
-
This folder contains three utilities:
|
|
10
|
-
|
|
11
|
-
* `draco_decoder.js` — Emscripten-compiled decoder, compatible with any modern browser.
|
|
12
|
-
* `draco_decoder.wasm` — WebAssembly decoder, compatible with newer browsers and devices.
|
|
13
|
-
* `draco_wasm_wrapper.js` — JavaScript wrapper for the WASM decoder.
|
|
14
|
-
|
|
15
|
-
Each file is provided in two variations:
|
|
16
|
-
|
|
17
|
-
* **Default:** Latest stable builds, tracking the project's [master branch](https://github.com/google/draco).
|
|
18
|
-
* **glTF:** Builds targeted by the [glTF mesh compression extension](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression), tracking the [corresponding Draco branch](https://github.com/google/draco/tree/gltf_2.0_draco_extension).
|
|
19
|
-
|
|
20
|
-
Either variation may be used with `THREE.DRACOLoader`:
|
|
21
|
-
|
|
22
|
-
```js
|
|
23
|
-
var dracoLoader = new THREE.DRACOLoader();
|
|
24
|
-
dracoLoader.setDecoderPath('path/to/decoders/');
|
|
25
|
-
dracoLoader.setDecoderConfig({type: 'js'}); // (Optional) Override detection of WASM support.
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Further [documentation on GitHub](https://github.com/google/draco/tree/master/javascript/example#static-loading-javascript-decoder).
|
|
29
|
-
|
|
30
|
-
## License
|
|
31
|
-
|
|
32
|
-
[Apache License 2.0](https://github.com/google/draco/blob/master/LICENSE)
|