@ridp/threejs 0.2.0 → 1.1.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.
Files changed (82) hide show
  1. package/dist/ImageLoader-CB_URfeZ.js +860 -0
  2. package/dist/ImageLoader-DwvBWW6h.cjs +5 -0
  3. package/dist/common-BHi3qsZW.cjs +15 -0
  4. package/dist/{common-DESmndxO.js → common-fbJUHqlj.js} +1 -1
  5. package/dist/hooks.cjs +1 -1
  6. package/dist/hooks.js +7 -9
  7. package/dist/threejs.cjs +1 -1
  8. package/dist/threejs.js +17 -15
  9. package/dist/useGLTFLoader-DHxBLucO.js +5629 -0
  10. package/dist/useGLTFLoader-DM3-7jdq.cjs +4 -0
  11. package/dist/utils.cjs +1 -1
  12. package/dist/utils.js +15 -12
  13. package/esdoc/ast/source/.external-ecmascript.js.json +2802 -0
  14. package/esdoc/ast/source/hooks/index.js.json +739 -0
  15. package/esdoc/ast/source/hooks/useGLTFLoader.js.json +9111 -0
  16. package/esdoc/ast/source/hooks/useObb.js.json +16463 -0
  17. package/esdoc/ast/source/hooks/useRaycaster.js.json +15556 -0
  18. package/esdoc/ast/source/hooks/useThreeJs.js.json +52887 -0
  19. package/esdoc/ast/source/index.js.json +570 -0
  20. package/esdoc/ast/source/instance/IDBCache.js.json +40978 -0
  21. package/esdoc/ast/source/instance/index.js.json +232 -0
  22. package/esdoc/ast/source/utils/ImageLoader.js.json +7037 -0
  23. package/esdoc/ast/source/utils/common.js.json +5134 -0
  24. package/esdoc/ast/source/utils/css3dHelper.js.json +9101 -0
  25. package/esdoc/ast/source/utils/disposeObject.js.json +5978 -0
  26. package/esdoc/ast/source/utils/helper.js.json +10522 -0
  27. package/esdoc/ast/source/utils/index.js.json +908 -0
  28. package/esdoc/badge.svg +17 -0
  29. package/esdoc/class/src/instance/IDBCache.js~IDBCache.html +1299 -0
  30. package/esdoc/coverage.json +86 -0
  31. package/esdoc/css/github.css +83 -0
  32. package/esdoc/css/identifiers.css +37 -0
  33. package/esdoc/css/manual.css +134 -0
  34. package/esdoc/css/prettify-tomorrow.css +132 -0
  35. package/esdoc/css/search.css +84 -0
  36. package/esdoc/css/source.css +55 -0
  37. package/esdoc/css/style.css +608 -0
  38. package/esdoc/css/test.css +58 -0
  39. package/esdoc/file/src/hooks/index.js.html +79 -0
  40. package/esdoc/file/src/hooks/useGLTFLoader.js.html +146 -0
  41. package/esdoc/file/src/hooks/useObb.js.html +149 -0
  42. package/esdoc/file/src/hooks/useRaycaster.js.html +153 -0
  43. package/esdoc/file/src/hooks/useThreeJs.js.html +362 -0
  44. package/esdoc/file/src/index.js.html +78 -0
  45. package/esdoc/file/src/instance/IDBCache.js.html +312 -0
  46. package/esdoc/file/src/instance/index.js.html +76 -0
  47. package/esdoc/file/src/utils/ImageLoader.js.html +118 -0
  48. package/esdoc/file/src/utils/common.js.html +102 -0
  49. package/esdoc/file/src/utils/css3dHelper.js.html +131 -0
  50. package/esdoc/file/src/utils/disposeObject.js.html +114 -0
  51. package/esdoc/file/src/utils/helper.js.html +138 -0
  52. package/esdoc/file/src/utils/index.js.html +80 -0
  53. package/esdoc/function/index.html +2019 -0
  54. package/esdoc/identifiers.html +738 -0
  55. package/esdoc/image/badge.svg +17 -0
  56. package/esdoc/image/esdoc-logo-mini-black.png +0 -0
  57. package/esdoc/image/esdoc-logo-mini.png +0 -0
  58. package/esdoc/image/manual-badge.svg +17 -0
  59. package/esdoc/image/search.png +0 -0
  60. package/esdoc/index.html +153 -0
  61. package/esdoc/index.json +2051 -0
  62. package/esdoc/inject/css/0-cus-style.css +1 -0
  63. package/esdoc/lint.json +1 -0
  64. package/esdoc/script/inherited-summary.js +28 -0
  65. package/esdoc/script/inner-link.js +32 -0
  66. package/esdoc/script/manual.js +12 -0
  67. package/esdoc/script/patch-for-local.js +8 -0
  68. package/esdoc/script/prettify/Apache-License-2.0.txt +202 -0
  69. package/esdoc/script/prettify/prettify.js +46 -0
  70. package/esdoc/script/pretty-print.js +25 -0
  71. package/esdoc/script/search.js +117 -0
  72. package/esdoc/script/search_index.js +572 -0
  73. package/esdoc/script/test-summary.js +54 -0
  74. package/esdoc/source.html +213 -0
  75. package/esdoc/variable/index.html +225 -0
  76. package/package.json +13 -3
  77. package/readme.md +93 -0
  78. package/dist/common-nMt4tIRA.cjs +0 -15
  79. package/dist/disposeObject-BuI3II7v.cjs +0 -1
  80. package/dist/disposeObject-CmFSSgi7.js +0 -616
  81. package/dist/useGLTFLoader-BAoIZjEX.js +0 -2645
  82. package/dist/useGLTFLoader-CGOxhEOO.cjs +0 -6
@@ -0,0 +1,79 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <base data-ice="baseUrl" href="../../../">
6
+ <title data-ice="title">src/hooks/index.js | @ridp/threejs</title>
7
+ <link type="text/css" rel="stylesheet" href="css/style.css">
8
+ <link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
9
+ <script src="script/prettify/prettify.js"></script>
10
+ <script src="script/manual.js"></script>
11
+ <link rel="stylesheet" href="./inject/css/0-cus-style.css"></head>
12
+ <body class="layout-container" data-ice="rootContainer">
13
+
14
+ <header>
15
+ <a href="./">Home</a>
16
+
17
+ <a href="identifiers.html">Reference</a>
18
+ <a href="source.html">Source</a>
19
+
20
+ <div class="search-box">
21
+ <span>
22
+ <img src="./image/search.png">
23
+ <span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
24
+ </span>
25
+ <ul class="search-result"></ul>
26
+ </div>
27
+ </header>
28
+
29
+ <nav class="navigation" data-ice="nav"><div>
30
+ <ul>
31
+
32
+ <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#hooks">hooks</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useGLTFLoader">useGLTFLoader</a></span></span></li>
33
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useObb">useObb</a></span></span></li>
34
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useRaycaster">useRaycaster</a></span></span></li>
35
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useThreeJs">useThreeJs</a></span></span></li>
36
+ <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-intersectColor">intersectColor</a></span></span></li>
37
+ <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-obbObjects">obbObjects</a></span></span></li>
38
+ <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#instance">instance</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/instance/IDBCache.js~IDBCache.html">IDBCache</a></span></span></li>
39
+ <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#utils">utils</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-ImageLoader">ImageLoader</a></span></span></li>
40
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-initEnvImage">initEnvImage</a></span></span></li>
41
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-getCommonParent">getCommonParent</a></span></span></li>
42
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createInfoPlane">createInfoPlane</a></span></span></li>
43
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createTagPlane">createTagPlane</a></span></span></li>
44
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-disposeThreeObject">disposeThreeObject</a></span></span></li>
45
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createArrowHelper">createArrowHelper</a></span></span></li>
46
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createAxesHelper">createAxesHelper</a></span></span></li>
47
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createBox3Helper">createBox3Helper</a></span></span></li>
48
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createCameraHelper">createCameraHelper</a></span></span></li>
49
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createGridHelper">createGridHelper</a></span></span></li>
50
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createMapControls">createMapControls</a></span></span></li>
51
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createOrbitControl">createOrbitControl</a></span></span></li>
52
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createRaycaster">createRaycaster</a></span></span></li>
53
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createStats">createStats</a></span></span></li>
54
+ </ul>
55
+ </div>
56
+ </nav>
57
+
58
+ <div class="content" data-ice="content"><h1 data-ice="title">src/hooks/index.js</h1>
59
+ <pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">export * from &quot;./useThreeJs&quot;;
60
+ export * from &quot;./useRaycaster&quot;;
61
+ export * from &quot;./useObb&quot;;
62
+ export * from &quot;./useGLTFLoader&quot;;
63
+ </code></pre>
64
+
65
+ </div>
66
+
67
+ <footer class="footer">
68
+ Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(1.1.0)</span><img src="./image/esdoc-logo-mini-black.png"></a>
69
+ </footer>
70
+
71
+ <script src="script/search_index.js"></script>
72
+ <script src="script/search.js"></script>
73
+ <script src="script/pretty-print.js"></script>
74
+ <script src="script/inherited-summary.js"></script>
75
+ <script src="script/test-summary.js"></script>
76
+ <script src="script/inner-link.js"></script>
77
+ <script src="script/patch-for-local.js"></script>
78
+ </body>
79
+ </html>
@@ -0,0 +1,146 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <base data-ice="baseUrl" href="../../../">
6
+ <title data-ice="title">src/hooks/useGLTFLoader.js | @ridp/threejs</title>
7
+ <link type="text/css" rel="stylesheet" href="css/style.css">
8
+ <link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
9
+ <script src="script/prettify/prettify.js"></script>
10
+ <script src="script/manual.js"></script>
11
+ <link rel="stylesheet" href="./inject/css/0-cus-style.css"></head>
12
+ <body class="layout-container" data-ice="rootContainer">
13
+
14
+ <header>
15
+ <a href="./">Home</a>
16
+
17
+ <a href="identifiers.html">Reference</a>
18
+ <a href="source.html">Source</a>
19
+
20
+ <div class="search-box">
21
+ <span>
22
+ <img src="./image/search.png">
23
+ <span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
24
+ </span>
25
+ <ul class="search-result"></ul>
26
+ </div>
27
+ </header>
28
+
29
+ <nav class="navigation" data-ice="nav"><div>
30
+ <ul>
31
+
32
+ <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#hooks">hooks</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useGLTFLoader">useGLTFLoader</a></span></span></li>
33
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useObb">useObb</a></span></span></li>
34
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useRaycaster">useRaycaster</a></span></span></li>
35
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useThreeJs">useThreeJs</a></span></span></li>
36
+ <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-intersectColor">intersectColor</a></span></span></li>
37
+ <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-obbObjects">obbObjects</a></span></span></li>
38
+ <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#instance">instance</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/instance/IDBCache.js~IDBCache.html">IDBCache</a></span></span></li>
39
+ <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#utils">utils</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-ImageLoader">ImageLoader</a></span></span></li>
40
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-initEnvImage">initEnvImage</a></span></span></li>
41
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-getCommonParent">getCommonParent</a></span></span></li>
42
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createInfoPlane">createInfoPlane</a></span></span></li>
43
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createTagPlane">createTagPlane</a></span></span></li>
44
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-disposeThreeObject">disposeThreeObject</a></span></span></li>
45
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createArrowHelper">createArrowHelper</a></span></span></li>
46
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createAxesHelper">createAxesHelper</a></span></span></li>
47
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createBox3Helper">createBox3Helper</a></span></span></li>
48
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createCameraHelper">createCameraHelper</a></span></span></li>
49
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createGridHelper">createGridHelper</a></span></span></li>
50
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createMapControls">createMapControls</a></span></span></li>
51
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createOrbitControl">createOrbitControl</a></span></span></li>
52
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createRaycaster">createRaycaster</a></span></span></li>
53
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createStats">createStats</a></span></span></li>
54
+ </ul>
55
+ </div>
56
+ </nav>
57
+
58
+ <div class="content" data-ice="content"><h1 data-ice="title">src/hooks/useGLTFLoader.js</h1>
59
+ <pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">import { GLTFLoader } from &quot;three/addons/loaders/GLTFLoader.js&quot;;
60
+ import { DRACOLoader } from &quot;three/addons/loaders/DRACOLoader.js&quot;;
61
+ import { IDBCache } from &quot;../instance/IDBCache&quot;;
62
+
63
+ /** @type { IDBCache } */
64
+ let idbCache;
65
+
66
+ /**
67
+ * GLTFLoader &#x6A21;&#x578B;&#x52A0;&#x8F7D;&#x5668;
68
+ * @returns { Object }
69
+ * @property { Function } load - &#x6A21;&#x578B;&#x52A0;&#x8F7D;&#x65B9;&#x6CD5;
70
+ * @property { Function } asyncLoad - Promise &#x5F62;&#x5F0F;&#x5F02;&#x6B65;&#x52A0;&#x8F7D;&#x6A21;&#x578B;&#x65B9;&#x6CD5;
71
+ * @property { Function } asyncCacheLoad - Promise &#x5F62;&#x5F0F;&#x5F02;&#x6B65;&#x52A0;&#x8F7D;&#x6A21;&#x578B;&#x5E76;&#x7F13;&#x5B58;&#x65B9;&#x6CD5;
72
+ */
73
+ export const useGLTFLoader = () =&gt; {
74
+ const loader = new GLTFLoader();
75
+ const dracoLoader = new DRACOLoader();
76
+ dracoLoader.setDecoderPath(`/draco/`);
77
+ loader.setDRACOLoader(dracoLoader);
78
+
79
+ /**
80
+ * &#x6A21;&#x578B;&#x52A0;&#x8F7D;
81
+ * @param { String } path - &#x6A21;&#x578B;&#x8DEF;&#x5F84;
82
+ * @param {Function} onLoad - &#x52A0;&#x8F7D;&#x5B8C;&#x6210;&#x56DE;&#x8C03;
83
+ * @param {Function} onProgress - &#x8FDB;&#x5EA6;&#x56DE;&#x8C03;
84
+ * @param {Function} onError - &#x9519;&#x8BEF;&#x56DE;&#x8C03;
85
+ * @returns { GLTFLoader.load }
86
+ */
87
+ function load(path, onLoad, onProgress, onError) {
88
+ return loader.load(path, onLoad, onProgress, onError);
89
+ }
90
+
91
+ /**
92
+ * Promise &#x5F62;&#x5F0F;&#x5F02;&#x6B65;&#x52A0;&#x8F7D;&#x6A21;&#x578B;
93
+ * @param {String} path - &#x6A21;&#x578B;&#x8DEF;&#x5F84;
94
+ * @param {Function} onProgress - &#x8FDB;&#x5EA6;&#x56DE;&#x8C03;
95
+ * @returns
96
+ */
97
+ function asyncLoad(path, onProgress) {
98
+ return new Promise((resolve, reject) =&gt; {
99
+ loader.load(path, resolve, onProgress, reject);
100
+ });
101
+ }
102
+
103
+ /**
104
+ * Promise &#x5F62;&#x5F0F;&#x5F02;&#x6B65;&#x52A0;&#x8F7D;&#x6A21;&#x578B;&#x5E76;&#x7F13;&#x5B58;
105
+ * &#x4F7F;&#x7528;IndexDb &#x5BF9;&#x52A0;&#x8F7D;&#x540E;&#x7684;&#x6A21;&#x578B;&#x6587;&#x4EF6;&#x8FDB;&#x884C;&#x7F13;&#x5B58;
106
+ * &#x4E8C;&#x6B21;&#x8BBF;&#x95EE;&#x65F6;&#x76F4;&#x63A5;&#x4ECE;&#x7F13;&#x5B58;&#x4E2D;&#x52A0;&#x8F7D;, &#x51CF;&#x5C11;&#x7F51;&#x7EDC;&#x8BF7;&#x6C42;
107
+ * @param {*} path - &#x6A21;&#x578B;&#x8DEF;&#x5F84;
108
+ * @param {*} onProgress - &#x8FDB;&#x5EA6;&#x56DE;&#x8C03;
109
+ * @returns { Object3D }
110
+ */
111
+ async function asyncCacheLoad(path, onProgress) {
112
+ if (!idbCache) idbCache = new IDBCache();
113
+ const cacheObj = await idbCache.loadCachedModel(path);
114
+ if (cacheObj) return cacheObj;
115
+
116
+ return new Promise((resolve, reject) =&gt; {
117
+ loader.load(path, resolve, onProgress, reject);
118
+ }).then(async (model) =&gt; {
119
+ await idbCache.cacheModel(path, model.scene);
120
+ return model;
121
+ });
122
+ }
123
+
124
+ return {
125
+ load,
126
+ asyncLoad,
127
+ asyncCacheLoad,
128
+ };
129
+ };
130
+ </code></pre>
131
+
132
+ </div>
133
+
134
+ <footer class="footer">
135
+ Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(1.1.0)</span><img src="./image/esdoc-logo-mini-black.png"></a>
136
+ </footer>
137
+
138
+ <script src="script/search_index.js"></script>
139
+ <script src="script/search.js"></script>
140
+ <script src="script/pretty-print.js"></script>
141
+ <script src="script/inherited-summary.js"></script>
142
+ <script src="script/test-summary.js"></script>
143
+ <script src="script/inner-link.js"></script>
144
+ <script src="script/patch-for-local.js"></script>
145
+ </body>
146
+ </html>
@@ -0,0 +1,149 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <base data-ice="baseUrl" href="../../../">
6
+ <title data-ice="title">src/hooks/useObb.js | @ridp/threejs</title>
7
+ <link type="text/css" rel="stylesheet" href="css/style.css">
8
+ <link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
9
+ <script src="script/prettify/prettify.js"></script>
10
+ <script src="script/manual.js"></script>
11
+ <link rel="stylesheet" href="./inject/css/0-cus-style.css"></head>
12
+ <body class="layout-container" data-ice="rootContainer">
13
+
14
+ <header>
15
+ <a href="./">Home</a>
16
+
17
+ <a href="identifiers.html">Reference</a>
18
+ <a href="source.html">Source</a>
19
+
20
+ <div class="search-box">
21
+ <span>
22
+ <img src="./image/search.png">
23
+ <span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
24
+ </span>
25
+ <ul class="search-result"></ul>
26
+ </div>
27
+ </header>
28
+
29
+ <nav class="navigation" data-ice="nav"><div>
30
+ <ul>
31
+
32
+ <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#hooks">hooks</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useGLTFLoader">useGLTFLoader</a></span></span></li>
33
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useObb">useObb</a></span></span></li>
34
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useRaycaster">useRaycaster</a></span></span></li>
35
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useThreeJs">useThreeJs</a></span></span></li>
36
+ <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-intersectColor">intersectColor</a></span></span></li>
37
+ <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-obbObjects">obbObjects</a></span></span></li>
38
+ <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#instance">instance</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/instance/IDBCache.js~IDBCache.html">IDBCache</a></span></span></li>
39
+ <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#utils">utils</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-ImageLoader">ImageLoader</a></span></span></li>
40
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-initEnvImage">initEnvImage</a></span></span></li>
41
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-getCommonParent">getCommonParent</a></span></span></li>
42
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createInfoPlane">createInfoPlane</a></span></span></li>
43
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createTagPlane">createTagPlane</a></span></span></li>
44
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-disposeThreeObject">disposeThreeObject</a></span></span></li>
45
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createArrowHelper">createArrowHelper</a></span></span></li>
46
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createAxesHelper">createAxesHelper</a></span></span></li>
47
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createBox3Helper">createBox3Helper</a></span></span></li>
48
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createCameraHelper">createCameraHelper</a></span></span></li>
49
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createGridHelper">createGridHelper</a></span></span></li>
50
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createMapControls">createMapControls</a></span></span></li>
51
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createOrbitControl">createOrbitControl</a></span></span></li>
52
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createRaycaster">createRaycaster</a></span></span></li>
53
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createStats">createStats</a></span></span></li>
54
+ </ul>
55
+ </div>
56
+ </nav>
57
+
58
+ <div class="content" data-ice="content"><h1 data-ice="title">src/hooks/useObb.js</h1>
59
+ <pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">import { Color, Box3, Vector3 } from &apos;three&apos;
60
+ import { OBB } from &apos;three/addons&apos;
61
+
62
+ // &#x6309;parentUid&#x5B58;&#x50A8;obb&#x5BF9;&#x8C61;, &#x7528;&#x4E8E;&#x78B0;&#x649E;&#x68C0;&#x6D4B;
63
+ export const obbObjects = []
64
+ export const intersectColor = new Color(0xff0000)
65
+
66
+ export const useObb = () =&gt; {
67
+ const resetObbs = () =&gt; {
68
+ obbObjects.splice(0)
69
+ }
70
+
71
+ const initObb = (parentUid, model) =&gt; {
72
+ model.traverse((child) =&gt; {
73
+ // &#x9700;&#x8981;&#x78B0;&#x649E;&#x68C0;&#x6D4B;&#x7684;&#x6807;&#x8BB0;
74
+ child &amp;&amp; initSingleObbItem(parentUid, child)
75
+ })
76
+ }
77
+
78
+ const initSingleObbItem = (parentUid, model) =&gt; {
79
+ if (model.userData.needCheck) {
80
+ model.autoUpdateMatrix = false
81
+ model.updateMatrix()
82
+ model.updateMatrixWorld()
83
+ if (model.isMesh) {
84
+ const box3 = new Box3(new Vector3()).setFromObject(model)
85
+
86
+ model.geometry.userData.obb = new OBB()
87
+ model.geometry.userData.obb.halfSize.copy(box3.getSize(new Vector3())).multiplyScalar(0.5).multiplyScalar(0.88)
88
+ model.userData.obb = new OBB()
89
+
90
+ model.userData.originColor = model.material.color.clone()
91
+ model.userData.parentUid = parentUid
92
+
93
+ obbObjects.push({
94
+ object: model,
95
+ parentUid: parentUid
96
+ })
97
+ }
98
+ }
99
+ }
100
+
101
+ const addObbFromArray = (parentUid, arr) =&gt; {
102
+ for (let i = 0, il = arr.length; i &lt; il; i++) {
103
+ initSingleObbItem(parentUid, arr[i])
104
+ }
105
+ }
106
+
107
+ const getObbObjectByParentUid = (parentUid) =&gt; {
108
+ return obbObjects.filter((item) =&gt; item.parentUid === parentUid)
109
+ }
110
+
111
+ const removeObbFromArray = (obbs) =&gt; {
112
+ const list = obbObjects.filter((item) =&gt; !obbs.includes(item.object))
113
+ obbObjects.splice(0, obbObjects.length, ...list)
114
+ }
115
+
116
+ const removeUidObb = (parentUid) =&gt; {
117
+ for (let i = obbObjects.length - 1; i &gt;= 0; i--) {
118
+ if (obbObjects[i].parentUid === parentUid) {
119
+ obbObjects.splice(i, 1)
120
+ }
121
+ }
122
+ }
123
+
124
+ return {
125
+ resetObbs,
126
+ initObb,
127
+ getObbObjectByParentUid,
128
+ addObbFromArray,
129
+ removeObbFromArray,
130
+ removeUidObb
131
+ }
132
+ }
133
+ </code></pre>
134
+
135
+ </div>
136
+
137
+ <footer class="footer">
138
+ Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(1.1.0)</span><img src="./image/esdoc-logo-mini-black.png"></a>
139
+ </footer>
140
+
141
+ <script src="script/search_index.js"></script>
142
+ <script src="script/search.js"></script>
143
+ <script src="script/pretty-print.js"></script>
144
+ <script src="script/inherited-summary.js"></script>
145
+ <script src="script/test-summary.js"></script>
146
+ <script src="script/inner-link.js"></script>
147
+ <script src="script/patch-for-local.js"></script>
148
+ </body>
149
+ </html>
@@ -0,0 +1,153 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <base data-ice="baseUrl" href="../../../">
6
+ <title data-ice="title">src/hooks/useRaycaster.js | @ridp/threejs</title>
7
+ <link type="text/css" rel="stylesheet" href="css/style.css">
8
+ <link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
9
+ <script src="script/prettify/prettify.js"></script>
10
+ <script src="script/manual.js"></script>
11
+ <link rel="stylesheet" href="./inject/css/0-cus-style.css"></head>
12
+ <body class="layout-container" data-ice="rootContainer">
13
+
14
+ <header>
15
+ <a href="./">Home</a>
16
+
17
+ <a href="identifiers.html">Reference</a>
18
+ <a href="source.html">Source</a>
19
+
20
+ <div class="search-box">
21
+ <span>
22
+ <img src="./image/search.png">
23
+ <span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
24
+ </span>
25
+ <ul class="search-result"></ul>
26
+ </div>
27
+ </header>
28
+
29
+ <nav class="navigation" data-ice="nav"><div>
30
+ <ul>
31
+
32
+ <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#hooks">hooks</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useGLTFLoader">useGLTFLoader</a></span></span></li>
33
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useObb">useObb</a></span></span></li>
34
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useRaycaster">useRaycaster</a></span></span></li>
35
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-useThreeJs">useThreeJs</a></span></span></li>
36
+ <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-intersectColor">intersectColor</a></span></span></li>
37
+ <li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-obbObjects">obbObjects</a></span></span></li>
38
+ <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#instance">instance</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/instance/IDBCache.js~IDBCache.html">IDBCache</a></span></span></li>
39
+ <li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#utils">utils</a><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-ImageLoader">ImageLoader</a></span></span></li>
40
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-initEnvImage">initEnvImage</a></span></span></li>
41
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-getCommonParent">getCommonParent</a></span></span></li>
42
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createInfoPlane">createInfoPlane</a></span></span></li>
43
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createTagPlane">createTagPlane</a></span></span></li>
44
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-disposeThreeObject">disposeThreeObject</a></span></span></li>
45
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createArrowHelper">createArrowHelper</a></span></span></li>
46
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createAxesHelper">createAxesHelper</a></span></span></li>
47
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createBox3Helper">createBox3Helper</a></span></span></li>
48
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createCameraHelper">createCameraHelper</a></span></span></li>
49
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createGridHelper">createGridHelper</a></span></span></li>
50
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createMapControls">createMapControls</a></span></span></li>
51
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createOrbitControl">createOrbitControl</a></span></span></li>
52
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createRaycaster">createRaycaster</a></span></span></li>
53
+ <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createStats">createStats</a></span></span></li>
54
+ </ul>
55
+ </div>
56
+ </nav>
57
+
58
+ <div class="content" data-ice="content"><h1 data-ice="title">src/hooks/useRaycaster.js</h1>
59
+ <pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">import { Raycaster, Vector2 } from &quot;three&quot;;
60
+
61
+ // Raycaster
62
+ export const useRaycaster = (appId = &quot;app&quot;) =&gt; {
63
+ const raycaster = new Raycaster();
64
+ raycaster.params.Line.threshold = 8;
65
+ const pointer = new Vector2();
66
+
67
+ const $app = document.getElementById(appId);
68
+
69
+ /**
70
+ * &#x83B7;&#x53D6;&#x9F20;&#x6807;&#x5750;&#x6807;
71
+ * @param {*} event HtmlEvent
72
+ * @param {*} container HTMLDomElement
73
+ * @returns
74
+ */
75
+ function getPointer(event, container) {
76
+ const { scaleX, scaleY } = getScale($app);
77
+ const { clientWidth, clientHeight } = container;
78
+ const size = container.getBoundingClientRect();
79
+
80
+ const realDomWidth = clientWidth * scaleX;
81
+ const realDomHeight = clientHeight * scaleY;
82
+
83
+ const x = event.clientX - size.left;
84
+ const y = event.clientY - size.top;
85
+ pointer.x = ((event.clientX - size.left) / realDomWidth) * 2 - 1;
86
+ pointer.y = -((event.clientY - size.top) / realDomHeight) * 2 + 1;
87
+ return { pointer, x, y };
88
+ }
89
+
90
+ /**
91
+ * &#x83B7;&#x53D6;&#x9F20;&#x6807;&#x6355;&#x83B7;&#x7684;&#x5BF9;&#x8C61;
92
+ * @param {*} event HtmlEvent
93
+ * @param {*} renderDom renderer.domElement
94
+ * @param {*} camera Camera
95
+ * @param {*} catchObjects Objects3D[]
96
+ * @returns Objects3D[] || null
97
+ */
98
+ function getIntersects(event, renderDom, camera, catchObjects) {
99
+ const { pointer, x, y } = getPointer(event, renderDom);
100
+ raycaster.setFromCamera(pointer, camera);
101
+ const intersects = raycaster.intersectObjects(catchObjects);
102
+ return { intersects, pointer, x, y };
103
+ }
104
+
105
+ /**
106
+ * &#x83B7;&#x53D6; DOM &#x7684;&#x7F29;&#x653E;&#x6BD4;&#x4F8B;
107
+ * @param {*} element
108
+ * @returns
109
+ */
110
+ function getScale(element) {
111
+ const style = window.getComputedStyle(element);
112
+ const transform =
113
+ style.transform || style.webkitTransform || style.mozTransform;
114
+
115
+ if (transform &amp;&amp; transform !== &quot;none&quot;) {
116
+ const matrix = transform.match(/^matrix\((.+)\)$/);
117
+ if (matrix) {
118
+ const values = matrix[1].split(&quot;, &quot;);
119
+ const scaleX = parseFloat(values[0]);
120
+ const scaleY = parseFloat(values[3]);
121
+ return { scaleX, scaleY };
122
+ }
123
+ }
124
+ // &#x5982;&#x679C;&#x6CA1;&#x6709;&#x7F29;&#x653E;&#xFF0C;&#x8FD4;&#x56DE;&#x9ED8;&#x8BA4;&#x503C;
125
+ return { scaleX: 1, scaleY: 1 };
126
+ }
127
+
128
+ return {
129
+ raycaster,
130
+ pointer,
131
+
132
+ getPointer,
133
+ getScale,
134
+ getIntersects,
135
+ };
136
+ };
137
+ </code></pre>
138
+
139
+ </div>
140
+
141
+ <footer class="footer">
142
+ Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(1.1.0)</span><img src="./image/esdoc-logo-mini-black.png"></a>
143
+ </footer>
144
+
145
+ <script src="script/search_index.js"></script>
146
+ <script src="script/search.js"></script>
147
+ <script src="script/pretty-print.js"></script>
148
+ <script src="script/inherited-summary.js"></script>
149
+ <script src="script/test-summary.js"></script>
150
+ <script src="script/inner-link.js"></script>
151
+ <script src="script/patch-for-local.js"></script>
152
+ </body>
153
+ </html>