three-render-objects 1.26.6 → 1.27.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,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
|
|
@@ -46,7 +46,7 @@ function styleInject(css, ref) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
var css_248z = ".scene-nav-info {\n bottom: 5px;\n width: 100%;\n text-align: center;\n color: slategrey;\n opacity: 0.7;\n font-size: 10px;\n}\n\n.scene-tooltip {\n color: lavender;\n font-size: 15px;\n}\n\n.scene-nav-info, .scene-tooltip {\n position: absolute;\n font-family: sans-serif;\n pointer-events: none;\n}\n\n.scene-container canvas:focus {\n outline: none;\n}";
|
|
49
|
+
var css_248z = ".scene-nav-info {\n bottom: 5px;\n width: 100%;\n text-align: center;\n color: slategrey;\n opacity: 0.7;\n font-size: 10px;\n}\n\n.scene-tooltip {\n top: 0;\n color: lavender;\n font-size: 15px;\n}\n\n.scene-nav-info, .scene-tooltip {\n position: absolute;\n font-family: sans-serif;\n pointer-events: none;\n}\n\n.scene-container canvas:focus {\n outline: none;\n}";
|
|
50
50
|
styleInject(css_248z);
|
|
51
51
|
|
|
52
52
|
function _defineProperty(obj, key, value) {
|
|
@@ -502,8 +502,10 @@ var threeRenderObjects = Kapsule__default["default"]({
|
|
|
502
502
|
state.pointerPos.y = ev.pageY - offset.top; // Move tooltip
|
|
503
503
|
|
|
504
504
|
state.toolTipElem.style.top = "".concat(state.pointerPos.y, "px");
|
|
505
|
-
state.toolTipElem.style.left = "".concat(state.pointerPos.x, "px");
|
|
506
|
-
|
|
505
|
+
state.toolTipElem.style.left = "".concat(state.pointerPos.x, "px"); // adjust horizontal position to not exceed canvas boundaries
|
|
506
|
+
|
|
507
|
+
state.toolTipElem.style.transform = "translate(-".concat(state.pointerPos.x / state.width * 100, "%, ").concat( // flip to above if near bottom
|
|
508
|
+
state.height - state.pointerPos.y < 100 ? 'calc(-100% - 8px)' : '21px', ")");
|
|
507
509
|
}
|
|
508
510
|
|
|
509
511
|
function getOffset(el) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Version 1.
|
|
1
|
+
// Version 1.27.0 three-render-objects - https://github.com/vasturiano/three-render-objects
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('three')) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['three'], factory) :
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
var css_248z = ".scene-nav-info {\n bottom: 5px;\n width: 100%;\n text-align: center;\n color: slategrey;\n opacity: 0.7;\n font-size: 10px;\n}\n\n.scene-tooltip {\n color: lavender;\n font-size: 15px;\n}\n\n.scene-nav-info, .scene-tooltip {\n position: absolute;\n font-family: sans-serif;\n pointer-events: none;\n}\n\n.scene-container canvas:focus {\n outline: none;\n}";
|
|
35
|
+
var css_248z = ".scene-nav-info {\n bottom: 5px;\n width: 100%;\n text-align: center;\n color: slategrey;\n opacity: 0.7;\n font-size: 10px;\n}\n\n.scene-tooltip {\n top: 0;\n color: lavender;\n font-size: 15px;\n}\n\n.scene-nav-info, .scene-tooltip {\n position: absolute;\n font-family: sans-serif;\n pointer-events: none;\n}\n\n.scene-container canvas:focus {\n outline: none;\n}";
|
|
36
36
|
styleInject(css_248z);
|
|
37
37
|
|
|
38
38
|
function _defineProperty(obj, key, value) {
|
|
@@ -660,9 +660,6 @@
|
|
|
660
660
|
_state = STATE.PAN;
|
|
661
661
|
break;
|
|
662
662
|
|
|
663
|
-
default:
|
|
664
|
-
_state = STATE.NONE;
|
|
665
|
-
|
|
666
663
|
}
|
|
667
664
|
|
|
668
665
|
}
|
|
@@ -825,7 +822,7 @@
|
|
|
825
822
|
|
|
826
823
|
case 2:
|
|
827
824
|
_state = STATE.TOUCH_ZOOM_PAN;
|
|
828
|
-
_moveCurr.copy( getMouseOnCircle( event.pageX - _movePrev.
|
|
825
|
+
_moveCurr.copy( getMouseOnCircle( event.pageX - _movePrev.x, event.pageY - _movePrev.y ) );
|
|
829
826
|
_movePrev.copy( _moveCurr );
|
|
830
827
|
break;
|
|
831
828
|
|
|
@@ -2427,7 +2424,7 @@
|
|
|
2427
2424
|
* Full-screen textured quad shader
|
|
2428
2425
|
*/
|
|
2429
2426
|
|
|
2430
|
-
|
|
2427
|
+
const CopyShader = {
|
|
2431
2428
|
|
|
2432
2429
|
uniforms: {
|
|
2433
2430
|
|
|
@@ -2457,8 +2454,9 @@
|
|
|
2457
2454
|
|
|
2458
2455
|
void main() {
|
|
2459
2456
|
|
|
2460
|
-
|
|
2461
|
-
gl_FragColor
|
|
2457
|
+
gl_FragColor = texture2D( tDiffuse, vUv );
|
|
2458
|
+
gl_FragColor.a *= opacity;
|
|
2459
|
+
|
|
2462
2460
|
|
|
2463
2461
|
}`
|
|
2464
2462
|
|
|
@@ -2703,18 +2701,12 @@
|
|
|
2703
2701
|
|
|
2704
2702
|
if ( renderTarget === undefined ) {
|
|
2705
2703
|
|
|
2706
|
-
const parameters = {
|
|
2707
|
-
minFilter: three$1.LinearFilter,
|
|
2708
|
-
magFilter: three$1.LinearFilter,
|
|
2709
|
-
format: three$1.RGBAFormat
|
|
2710
|
-
};
|
|
2711
|
-
|
|
2712
2704
|
const size = renderer.getSize( new three$1.Vector2() );
|
|
2713
2705
|
this._pixelRatio = renderer.getPixelRatio();
|
|
2714
2706
|
this._width = size.width;
|
|
2715
2707
|
this._height = size.height;
|
|
2716
2708
|
|
|
2717
|
-
renderTarget = new three$1.WebGLRenderTarget( this._width * this._pixelRatio, this._height * this._pixelRatio
|
|
2709
|
+
renderTarget = new three$1.WebGLRenderTarget( this._width * this._pixelRatio, this._height * this._pixelRatio );
|
|
2718
2710
|
renderTarget.texture.name = 'EffectComposer.rt1';
|
|
2719
2711
|
|
|
2720
2712
|
} else {
|
|
@@ -3009,7 +3001,7 @@
|
|
|
3009
3001
|
}
|
|
3010
3002
|
|
|
3011
3003
|
function _extends() {
|
|
3012
|
-
_extends = Object.assign
|
|
3004
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
3013
3005
|
for (var i = 1; i < arguments.length; i++) {
|
|
3014
3006
|
var source = arguments[i];
|
|
3015
3007
|
|
|
@@ -3022,7 +3014,6 @@
|
|
|
3022
3014
|
|
|
3023
3015
|
return target;
|
|
3024
3016
|
};
|
|
3025
|
-
|
|
3026
3017
|
return _extends.apply(this, arguments);
|
|
3027
3018
|
}
|
|
3028
3019
|
|
|
@@ -3035,11 +3026,10 @@
|
|
|
3035
3026
|
}
|
|
3036
3027
|
|
|
3037
3028
|
function _setPrototypeOf(o, p) {
|
|
3038
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
3029
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
3039
3030
|
o.__proto__ = p;
|
|
3040
3031
|
return o;
|
|
3041
3032
|
};
|
|
3042
|
-
|
|
3043
3033
|
return _setPrototypeOf(o, p);
|
|
3044
3034
|
}
|
|
3045
3035
|
|
|
@@ -3050,7 +3040,7 @@
|
|
|
3050
3040
|
}
|
|
3051
3041
|
|
|
3052
3042
|
function _getPrototypeOf(o) {
|
|
3053
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
3043
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
3054
3044
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
3055
3045
|
};
|
|
3056
3046
|
return _getPrototypeOf(o);
|
|
@@ -3075,7 +3065,7 @@
|
|
|
3075
3065
|
|
|
3076
3066
|
function _construct(Parent, args, Class) {
|
|
3077
3067
|
if (_isNativeReflectConstruct()) {
|
|
3078
|
-
_construct = Reflect.construct;
|
|
3068
|
+
_construct = Reflect.construct.bind();
|
|
3079
3069
|
} else {
|
|
3080
3070
|
_construct = function _construct(Parent, args, Class) {
|
|
3081
3071
|
var a = [null];
|
|
@@ -3480,10 +3470,10 @@
|
|
|
3480
3470
|
var hexRgbaRegex = /^#[a-fA-F0-9]{8}$/;
|
|
3481
3471
|
var reducedHexRegex = /^#[a-fA-F0-9]{3}$/;
|
|
3482
3472
|
var reducedRgbaHexRegex = /^#[a-fA-F0-9]{4}$/;
|
|
3483
|
-
var rgbRegex = /^rgb\(\s*(\d{1,3})\s
|
|
3484
|
-
var rgbaRegex = /^
|
|
3485
|
-
var hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+)\s
|
|
3486
|
-
var hslaRegex = /^
|
|
3473
|
+
var rgbRegex = /^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i;
|
|
3474
|
+
var rgbaRegex = /^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
|
|
3475
|
+
var hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i;
|
|
3476
|
+
var hslaRegex = /^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
|
|
3487
3477
|
/**
|
|
3488
3478
|
* Returns an RgbColor or RgbaColor object. This utility function is only useful
|
|
3489
3479
|
* if want to extract a color component. With the color util `toColorString` you
|
|
@@ -3557,7 +3547,7 @@
|
|
|
3557
3547
|
red: parseInt("" + rgbaMatched[1], 10),
|
|
3558
3548
|
green: parseInt("" + rgbaMatched[2], 10),
|
|
3559
3549
|
blue: parseInt("" + rgbaMatched[3], 10),
|
|
3560
|
-
alpha: parseFloat("" + rgbaMatched[4])
|
|
3550
|
+
alpha: parseFloat("" + rgbaMatched[4]) > 1 ? parseFloat("" + rgbaMatched[4]) / 100 : parseFloat("" + rgbaMatched[4])
|
|
3561
3551
|
};
|
|
3562
3552
|
}
|
|
3563
3553
|
|
|
@@ -3602,7 +3592,7 @@
|
|
|
3602
3592
|
red: parseInt("" + _hslRgbMatched[1], 10),
|
|
3603
3593
|
green: parseInt("" + _hslRgbMatched[2], 10),
|
|
3604
3594
|
blue: parseInt("" + _hslRgbMatched[3], 10),
|
|
3605
|
-
alpha: parseFloat("" + hslaMatched[4])
|
|
3595
|
+
alpha: parseFloat("" + hslaMatched[4]) > 1 ? parseFloat("" + hslaMatched[4]) / 100 : parseFloat("" + hslaMatched[4])
|
|
3606
3596
|
};
|
|
3607
3597
|
}
|
|
3608
3598
|
|
|
@@ -5240,8 +5230,10 @@
|
|
|
5240
5230
|
state.pointerPos.y = ev.pageY - offset.top; // Move tooltip
|
|
5241
5231
|
|
|
5242
5232
|
state.toolTipElem.style.top = "".concat(state.pointerPos.y, "px");
|
|
5243
|
-
state.toolTipElem.style.left = "".concat(state.pointerPos.x, "px");
|
|
5244
|
-
|
|
5233
|
+
state.toolTipElem.style.left = "".concat(state.pointerPos.x, "px"); // adjust horizontal position to not exceed canvas boundaries
|
|
5234
|
+
|
|
5235
|
+
state.toolTipElem.style.transform = "translate(-".concat(state.pointerPos.x / state.width * 100, "%, ").concat( // flip to above if near bottom
|
|
5236
|
+
state.height - state.pointerPos.y < 100 ? 'calc(-100% - 8px)' : '21px', ")");
|
|
5245
5237
|
}
|
|
5246
5238
|
|
|
5247
5239
|
function getOffset(el) {
|