@galacean/effects-threejs 0.0.0-experimental-downgrade624-20240904

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 ADDED
@@ -0,0 +1,22 @@
1
+ MIT LICENSE
2
+
3
+ Copyright (c) 2019-present Ant Group Co., Ltd. https://www.antgroup.com/
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # Galacean Effects THREE.JS Plugin
2
+
3
+ With this plugin, you can load and render Galacean Effects animations within the THREE.JS environment.
4
+
5
+ ## Version Information
6
+
7
+ - Three.js ![](https://img.shields.io/badge/npm-0.149.0-green.svg?style=flat-square)
8
+
9
+ ## Usage
10
+
11
+ ### 1、THREE.JS Scene Initialization
12
+
13
+ o implement Galacean Effects in THREE.JS, you need to first create a THREE.JS scene:
14
+
15
+ ``` ts
16
+ import * as THREE from 'three';
17
+
18
+ // Create a renderer
19
+ const renderer = new THREE.WebGLRenderer({
20
+ alpha: true,
21
+ stencil: true,
22
+ antialias: true,
23
+ depth: true,
24
+ premultipliedAlpha: true,
25
+ });
26
+ // Create a scene
27
+ const scene = new THREE.Scene();
28
+ const container = document.getElementById('J-container');
29
+ const { width, height } = container.getBoundingClientRect();
30
+ // Create a camera
31
+ const camera = new THREE.PerspectiveCamera(80, width / height, 0.1, 1000);
32
+
33
+ camera.position.set(0, 0, 8);
34
+ camera.lookAt(0, 0, 0);
35
+ scene.add(camera);
36
+ renderer.setPixelRatio(window.devicePixelRatio);
37
+ renderer.setSize(width, height);
38
+
39
+ container.appendChild(renderer.domElement);
40
+ ```
41
+
42
+ ### 2、ThreeDisplayObject Instantiation and Resource Loading
43
+
44
+ ``` ts
45
+ import { ThreeDisplayObject } from '@galacean/effects-threejs';
46
+
47
+ const displayObject = new ThreeDisplayObject(renderer.getContext(), { width, height });
48
+ // Load Galacean Effects output
49
+ await displayObject.loadScene('./xxx.json');
50
+ // Add the rendering object to the THREE scene
51
+ scene.add(displayObject);
52
+ ```
53
+
54
+ ### 3、Perform THREE.JS Renderingts
55
+
56
+ ``` ts
57
+ const { currentComposition } = displayObject;
58
+ let lastTime = performance.now();
59
+
60
+ function render () {
61
+ // Check if the current composition has been destroyed
62
+ if (!currentComposition.isDestroyed) {
63
+ displayObject.update(performance.now() - lastTime);
64
+ }
65
+
66
+ lastTime = performance.now();
67
+ renderer.render(scene, camera);
68
+
69
+ requestAnimationFrame(render);
70
+ }
71
+
72
+ render();
73
+ ```
74
+
75
+ ## [API Documentation](https://galacean.antgroup.com/effects/#/api/modules_galacean_effects_threejs)
@@ -0,0 +1,6 @@
1
+ export * from '@galacean/effects-core';
2
+ export * from './three-display-object';
3
+ export * from './three-texture';
4
+ export * from './material';
5
+ export * from './three-composition';
6
+ export declare const version: string;