threedviewer 0.4.1 → 0.6.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/README.md CHANGED
@@ -3,12 +3,15 @@
3
3
 
4
4
  ThreeDViewer is a React component library for easily integrating Three.js-based 3D viewers into your web applications. It provides a simple and customizable way to display and interact with 3D objects in your React projects.
5
5
 
6
+ ![ThreeDGizmo Preview](https://github.com/LEMing/ThreeDViewer/raw/main/src/assets/cover.png)
7
+
6
8
  ## Features
7
9
 
8
10
  - Easy integration with React applications
9
11
  - Customizable viewer settings
10
12
  - Support for various 3D object formats
11
- - Built-in camera controls
13
+ - Built-in camera and map controls
14
+ - Optional gizmo controller
12
15
  - Responsive design
13
16
  - Ability to handle external scenes and Three.js objects
14
17
 
@@ -100,6 +103,7 @@ function App() {
100
103
  ...defaultOptions.helpers,
101
104
  grid: true,
102
105
  axes: true,
106
+ addGizmo: true, // New gizmo option
103
107
  },
104
108
  threeBaseRefs: {
105
109
  scene: sceneRef,
@@ -137,35 +141,84 @@ Props:
137
141
  `SimpleViewer` accepts an `options` prop for customization. Here's an overview of available options:
138
142
 
139
143
  ```javascript
140
- const defaultOptions = {
141
- staticScene: true, // Stops rendering if there is no activity
142
- backgroundColor: '#f0f0f7',
144
+ const defaultOptions: SimpleViewerOptions = {
145
+ staticScene: true, // It stops animation loop if there is no interactions
146
+ backgroundColor: '#f0f0f7', // From BACKGROUND_COLOR constant
143
147
  camera: {
144
- position: [6, 2, 1.2],
145
- target: [0, 0, 0],
146
- fov: 75,
147
- near: 0.1,
148
- far: 100000
149
- },
150
- lights: {
151
- ambient: { color: '#404040', intensity: 1 },
152
- hemisphere: { skyColor: '#ffffbb', groundColor: '#080820', intensity: 1 },
153
- directional: { color: '#ffffff', intensity: 1, position: [6, 6, 6], castShadow: true }
154
- },
148
+ cameraPosition: [2, 6, 2],
149
+ cameraTarget: [0, 0, 0], // Center of the scene
150
+ cameraFov: 75, // From initializeCamera
151
+ cameraNear: 0.1, // From initializeCamera
152
+ cameraFar: 100000, // From initializeCamera
153
+ autoFitToObject: true,
154
+ },
155
+ lightning: {
156
+ ambientLight: {
157
+ color: '#404040',
158
+ intensity: Math.PI,
159
+ },
160
+ hemisphereLight: {
161
+ skyColor: '#ffffbb',
162
+ groundColor: '#080820',
163
+ intensity: 1,
164
+ },
165
+ directionalLight: {
166
+ color: '#ffffff',
167
+ intensity: Math.PI,
168
+ position: new THREE.Vector3(6, 6, 6),
169
+ castShadow: true,
170
+ shadow: {
171
+ mapSize: {
172
+ width: 4096,
173
+ height: 4096,
174
+ },
175
+ camera: {
176
+ near: 0.5,
177
+ far: 50,
178
+ left: -10,
179
+ right: 10,
180
+ top: 10,
181
+ bottom: -10,
182
+ },
183
+ bias: -0.001,
184
+ radius: 1,
185
+ },
186
+ },
187
+ },
188
+ renderer: {
189
+ antialias: true,
190
+ alpha: false,
191
+ shadowMapEnabled: true,
192
+ pixelRatio: window.devicePixelRatio,
193
+ shadowMapType: THREE.VSMShadowMap,
194
+ toneMapping: THREE.ACESFilmicToneMapping,
195
+ toneMappingExposure: 1,
196
+ },
155
197
  controls: {
156
- enableDamping: true,
157
- dampingFactor: 0.25,
158
- enableZoom: true,
159
- enableRotate: true,
160
- enablePan: true
161
- },
198
+ type: ControlType.OrbitControls, // 'OrbitControls' or 'MapControls'
199
+ enabled: true, // Controls are used in setupScene
200
+ enableDamping: true, // From setupScene
201
+ dampingFactor: 0.25, // From setupScene
202
+ enableZoom: true, // From setupScene
203
+ enableRotate: true, // Default for OrbitControls
204
+ enablePan: true, // Default for OrbitControls
205
+ },
162
206
  helpers: {
163
- grid: true,
164
- axes: false,
165
- boundingBox: true
166
- },
167
- animationLoop: null, // External animation function
168
- }
207
+ gridHelper: true,
208
+ color: '#333333',
209
+ axesHelper: false,
210
+ object3DHelper: false,
211
+ addGizmo: false, // new Gizmo control is disabled by default
212
+ },
213
+ threeBaseRefs: {
214
+ mountPoint: {current: null},
215
+ scene: { current: null },
216
+ camera: { current: null },
217
+ renderer: { current: null },
218
+ controls: { current: null },
219
+ },
220
+ animationLoop: null,
221
+ };
169
222
  ```
170
223
 
171
224
  To use custom options, simply pass them to the `options` prop:
@@ -1,6 +1,6 @@
1
1
  import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
2
- import { THREEBase } from './types';
3
2
  import { SimpleViewerOptions } from '../types';
3
+ import { THREEBase } from './types';
4
4
  import * as THREE from 'three';
5
5
  export declare const setupScene: (threeBase: THREEBase, object: THREE.Object3D | null, options: SimpleViewerOptions) => {
6
6
  scene: THREE.Scene;