three-render-objects 1.26.3 → 1.26.7
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 +12 -12
- package/dist/three-render-objects.common.js +16 -9
- package/dist/three-render-objects.d.ts +1 -2
- package/dist/three-render-objects.js +317 -204
- package/dist/three-render-objects.js.map +1 -1
- package/dist/three-render-objects.min.js +2 -2
- package/dist/three-render-objects.module.js +12 -5
- package/package.json +17 -17
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ three-render-objects
|
|
|
3
3
|
|
|
4
4
|
[![NPM package][npm-img]][npm-url]
|
|
5
5
|
[![Build Size][build-size-img]][build-size-url]
|
|
6
|
-
[![
|
|
6
|
+
[![NPM Downloads][npm-downloads-img]][npm-downloads-url]
|
|
7
7
|
|
|
8
8
|
This module offers a convenient way to render [ThreeJS](https://threejs.org/) objects onto a WebGL canvas, with built-in interaction capabilities:
|
|
9
9
|
* hover/click events
|
|
@@ -15,28 +15,28 @@ All the renderer/scene/camera scaffolding is already included and any instance o
|
|
|
15
15
|
|
|
16
16
|
## Quick start
|
|
17
17
|
|
|
18
|
-
```
|
|
18
|
+
```js
|
|
19
19
|
import ThreeRenderObjects from 'three-render-objects';
|
|
20
20
|
```
|
|
21
21
|
or
|
|
22
|
-
```
|
|
23
|
-
|
|
22
|
+
```js
|
|
23
|
+
const ThreeRenderObjects = require('three-render-objects');
|
|
24
24
|
```
|
|
25
25
|
or even
|
|
26
|
-
```
|
|
26
|
+
```html
|
|
27
27
|
<script src="//unpkg.com/three-render-objects"></script>
|
|
28
28
|
```
|
|
29
29
|
then
|
|
30
|
-
```
|
|
30
|
+
```js
|
|
31
31
|
const myCanvas = ThreeRenderObjects();
|
|
32
32
|
myCanvas(<myDOMElement>)
|
|
33
|
-
|
|
33
|
+
.objects(<myData>);
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
## API reference
|
|
37
37
|
|
|
38
38
|
### Initialisation
|
|
39
|
-
```
|
|
39
|
+
```js
|
|
40
40
|
ThreeRenderObjects({ configOptions })(<domElement>)
|
|
41
41
|
```
|
|
42
42
|
|
|
@@ -104,9 +104,9 @@ ThreeRenderObjects({ configOptions })(<domElement>)
|
|
|
104
104
|
| <b>getSceneCoords</b>(<i>x</i>, <i>y</i>, <i>distance</i>) | Utility method to translate viewport distance coordinates to the scene 3D domain. Given a set of `x`,`y` viewport coordinates and distance from the camera, returns the current equivalent `{x, y, z}` in 3D scene coordinates. If no distance is provided, defaults to `0`. |
|
|
105
105
|
| <b>intersectingObjects</b>(<i>x</i>, <i>y</i>) | Utility method to retrieve the list of objects under the line of sight of the given viewport coordinates. Returns an array of [intersectObject](https://threejs.org/docs/#api/en/core/Raycaster.intersectObject), sorted by distance (from closest to farthest). |
|
|
106
106
|
|
|
107
|
-
[npm-img]: https://img.shields.io/npm/v/three-render-objects
|
|
107
|
+
[npm-img]: https://img.shields.io/npm/v/three-render-objects
|
|
108
108
|
[npm-url]: https://npmjs.org/package/three-render-objects
|
|
109
|
-
[build-size-img]: https://img.shields.io/bundlephobia/minzip/three-render-objects
|
|
109
|
+
[build-size-img]: https://img.shields.io/bundlephobia/minzip/three-render-objects
|
|
110
110
|
[build-size-url]: https://bundlephobia.com/result?p=three-render-objects
|
|
111
|
-
[
|
|
112
|
-
[
|
|
111
|
+
[npm-downloads-img]: https://img.shields.io/npm/dt/three-render-objects
|
|
112
|
+
[npm-downloads-url]: https://www.npmtrends.com/three-render-objects
|
|
@@ -85,7 +85,7 @@ function _iterableToArray(iter) {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
function _iterableToArrayLimit(arr, i) {
|
|
88
|
-
var _i = arr
|
|
88
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
89
89
|
|
|
90
90
|
if (_i == null) return;
|
|
91
91
|
var _arr = [];
|
|
@@ -160,7 +160,7 @@ var three = window.THREE ? window.THREE // Prefer consumption from global THREE,
|
|
|
160
160
|
Spherical: three$1.Spherical,
|
|
161
161
|
Clock: three$1.Clock
|
|
162
162
|
};
|
|
163
|
-
var threeRenderObjects = Kapsule__default[
|
|
163
|
+
var threeRenderObjects = Kapsule__default["default"]({
|
|
164
164
|
props: {
|
|
165
165
|
width: {
|
|
166
166
|
"default": window.innerWidth,
|
|
@@ -266,12 +266,12 @@ var threeRenderObjects = Kapsule__default['default']({
|
|
|
266
266
|
|
|
267
267
|
if (topObject !== state.hoverObj) {
|
|
268
268
|
state.onHover(topObject, state.hoverObj);
|
|
269
|
-
state.toolTipElem.innerHTML = topObject ? accessorFn__default[
|
|
269
|
+
state.toolTipElem.innerHTML = topObject ? accessorFn__default["default"](state.tooltipContent)(topObject) || '' : '';
|
|
270
270
|
state.hoverObj = topObject;
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
TWEEN__default[
|
|
274
|
+
TWEEN__default["default"].update(); // update camera animation tweens
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
return this;
|
|
@@ -303,9 +303,9 @@ var threeRenderObjects = Kapsule__default['default']({
|
|
|
303
303
|
} else {
|
|
304
304
|
var camPos = Object.assign({}, camera.position);
|
|
305
305
|
var camLookAt = getLookAt();
|
|
306
|
-
new TWEEN__default[
|
|
306
|
+
new TWEEN__default["default"].Tween(camPos).to(finalPos, transitionDuration).easing(TWEEN__default["default"].Easing.Quadratic.Out).onUpdate(setCameraPos).start(); // Face direction in 1/3rd of time
|
|
307
307
|
|
|
308
|
-
new TWEEN__default[
|
|
308
|
+
new TWEEN__default["default"].Tween(camLookAt).to(finalLookAt, transitionDuration / 3).easing(TWEEN__default["default"].Easing.Quadratic.Out).onUpdate(setLookAt).start();
|
|
309
309
|
}
|
|
310
310
|
|
|
311
311
|
return this;
|
|
@@ -326,7 +326,14 @@ var threeRenderObjects = Kapsule__default['default']({
|
|
|
326
326
|
}
|
|
327
327
|
|
|
328
328
|
function setLookAt(lookAt) {
|
|
329
|
-
|
|
329
|
+
var lookAtVect = new three.Vector3(lookAt.x, lookAt.y, lookAt.z);
|
|
330
|
+
|
|
331
|
+
if (state.controls.target) {
|
|
332
|
+
state.controls.target = lookAtVect;
|
|
333
|
+
} else {
|
|
334
|
+
// Fly controls doesn't have target attribute
|
|
335
|
+
camera.lookAt(lookAtVect); // note: lookAt may be overridden by other controls in some cases
|
|
336
|
+
}
|
|
330
337
|
}
|
|
331
338
|
|
|
332
339
|
function getLookAt() {
|
|
@@ -607,8 +614,8 @@ var threeRenderObjects = Kapsule__default['default']({
|
|
|
607
614
|
update: function update(state, changedProps) {
|
|
608
615
|
// resize canvas
|
|
609
616
|
if (state.width && state.height && (changedProps.hasOwnProperty('width') || changedProps.hasOwnProperty('height'))) {
|
|
610
|
-
state.container.style.width = state.width;
|
|
611
|
-
state.container.style.height = state.height;
|
|
617
|
+
state.container.style.width = "".concat(state.width, "px");
|
|
618
|
+
state.container.style.height = "".concat(state.height, "px");
|
|
612
619
|
[state.renderer, state.postProcessingComposer].concat(_toConsumableArray(state.extraRenderers)).forEach(function (r) {
|
|
613
620
|
return r.setSize(state.width, state.height);
|
|
614
621
|
});
|
|
@@ -81,5 +81,4 @@ type ThreeRenderObjectsInstance = ThreeRenderObjectsGenericInstance<ThreeRenderO
|
|
|
81
81
|
|
|
82
82
|
declare function ThreeRenderObjects(configOptions?: ConfigOptions): ThreeRenderObjectsInstance;
|
|
83
83
|
|
|
84
|
-
export default
|
|
85
|
-
export { ConfigOptions, ThreeRenderObjectsGenericInstance, ThreeRenderObjectsInstance };
|
|
84
|
+
export { ConfigOptions, ThreeRenderObjectsGenericInstance, ThreeRenderObjectsInstance, ThreeRenderObjects as default };
|