@realsee/five 6.4.3 → 6.5.0-alpha.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 (167) hide show
  1. package/docs/assets/navigation.js +1 -1
  2. package/docs/assets/search.js +1 -1
  3. package/docs/classes/five.BoxBoundingVolume.html +2 -2
  4. package/docs/classes/five.Camera.html +7 -7
  5. package/docs/classes/five.CullingVolume.html +2 -2
  6. package/docs/classes/five.Five.html +69 -81
  7. package/docs/classes/five.InternalWebGLRenderer.html +1 -1
  8. package/docs/classes/five.Model.html +55 -43
  9. package/docs/classes/five.ModelScene.html +38 -0
  10. package/docs/classes/five.Motion.html +17 -0
  11. package/docs/classes/five.PBMContainer.html +4 -12
  12. package/docs/classes/five.PBMCustomShader.html +11 -0
  13. package/docs/classes/five.PBMMaterial.html +2 -0
  14. package/docs/classes/five.PBMMesh.html +2 -4
  15. package/docs/classes/five.PBMMeshMaterial.html +27 -57
  16. package/docs/classes/five.PBMPointCloud.html +2 -3
  17. package/docs/classes/five.PBMPointCloudMaterial.html +15 -51
  18. package/docs/classes/five.PBMSkinnedMesh.html +2 -3
  19. package/docs/classes/five.Parameter.html +113 -0
  20. package/docs/classes/five.RegionBoundingVolume.html +2 -2
  21. package/docs/classes/five.Scene.html +6 -4
  22. package/docs/classes/five.SphereBoundingVolume.html +2 -2
  23. package/docs/classes/five.TextureLoader.html +2 -3
  24. package/docs/classes/five.Tile.html +2 -2
  25. package/docs/classes/five.Tile3DModel.html +55 -34
  26. package/docs/classes/five.TileNode.html +2 -2
  27. package/docs/classes/five.TileRequestScheduler.html +2 -2
  28. package/docs/classes/five.Tileset.html +4 -31
  29. package/docs/classes/five.Trajectory.html +2 -2
  30. package/docs/classes/five.TrajectoryNode.html +2 -2
  31. package/docs/classes/five.Work.html +17 -15
  32. package/docs/classes/gltf_loader.GLTFParser.html +1 -1
  33. package/docs/classes/sticker.Sticker.html +1 -1
  34. package/docs/functions/five.loadAt3d.html +1 -1
  35. package/docs/functions/five.loadB3dm.html +1 -1
  36. package/docs/functions/five.loadDome.html +1 -1
  37. package/docs/functions/five.loadDomez.html +1 -1
  38. package/docs/functions/five.loadFbx.html +1 -1
  39. package/docs/functions/five.loadGltf.html +1 -1
  40. package/docs/functions/five.loadPbm.html +1 -1
  41. package/docs/functions/five.loadPly.html +1 -1
  42. package/docs/functions/five.loadPnts.html +1 -1
  43. package/docs/functions/five.loadX3p.html +1 -1
  44. package/docs/functions/five.parseWork.html +1 -1
  45. package/docs/functions/react.useFiveCurrentObserver.html +2 -2
  46. package/docs/functions/react.withFive.html +1 -1
  47. package/docs/hierarchy.html +1 -1
  48. package/docs/interfaces/five.BaseEvent.html +1 -1
  49. package/docs/interfaces/five.BoundingVolume.html +2 -2
  50. package/docs/interfaces/five.CameraPose.html +2 -2
  51. package/docs/interfaces/five.EventCallback.html +3 -3
  52. package/docs/interfaces/five.FiveInitArgs.html +2 -2
  53. package/docs/interfaces/five.FiveLoadOptions.html +6 -6
  54. package/docs/interfaces/five.Intersection.html +2 -2
  55. package/docs/interfaces/five.LoosePanoWork.html +2 -2
  56. package/docs/interfaces/five.MapviewControllerCustomInitArgs.html +9 -9
  57. package/docs/interfaces/five.ModelLike.html +3 -0
  58. package/docs/interfaces/five.ModelSceneEvent.html +6 -0
  59. package/docs/interfaces/five.PBMClipperParameter.html +3 -0
  60. package/docs/interfaces/five.PBMCustomShaderInitArgs.html +6 -0
  61. package/docs/interfaces/five.PBMCustomShaderSlots.html +3 -0
  62. package/docs/interfaces/five.PBMMeshMaterialParameters.html +29 -0
  63. package/docs/interfaces/five.PBMPanoDepth.html +9 -0
  64. package/docs/interfaces/five.PBMPanoPicture.html +9 -7
  65. package/docs/interfaces/five.PBMPointCloudMaterialParameters.html +27 -0
  66. package/docs/interfaces/five.PBMRefinedScreen.html +6 -0
  67. package/docs/interfaces/five.PanoramaControllerCustomInitArgs.html +10 -10
  68. package/docs/interfaces/five.ParameterMaterialValue.html +71 -0
  69. package/docs/interfaces/five.ParameterTilesetValue.html +32 -0
  70. package/docs/interfaces/five.ParameterValue.html +102 -0
  71. package/docs/interfaces/five.ResolvedParameterValue.html +103 -0
  72. package/docs/interfaces/five.Tile3DModelLoaderOptions.html +4 -4
  73. package/docs/interfaces/five.TileCubeNode.html +2 -2
  74. package/docs/interfaces/five.TileCubeTree.html +2 -2
  75. package/docs/interfaces/five.TilesetHeader.html +5 -4
  76. package/docs/interfaces/five.TilesetOptions.html +2 -2
  77. package/docs/interfaces/five.VRPanoramaControllerCustomInitArgs.html +10 -10
  78. package/docs/interfaces/five.WorkCubeImage.html +7 -9
  79. package/docs/interfaces/five.WorkImage.html +10 -12
  80. package/docs/interfaces/five.WorkInitial.html +8 -8
  81. package/docs/interfaces/five.WorkModel.html +6 -6
  82. package/docs/interfaces/five.WorkModelLayer.html +2 -2
  83. package/docs/interfaces/five.WorkObserver.html +30 -20
  84. package/docs/interfaces/five.WorkResolvedObserver.html +22 -21
  85. package/docs/interfaces/five.WorkTile.html +16 -7
  86. package/docs/interfaces/five.WorkVideo.html +4 -4
  87. package/docs/interfaces/five.XRPanoramaControllerCustomInitArgs.html +10 -10
  88. package/docs/interfaces/gltf_loader.DDS.html +2 -2
  89. package/docs/interfaces/gltf_loader.GLTFReference.html +2 -2
  90. package/docs/interfaces/react.FiveInjectionTypes.html +9 -8
  91. package/docs/modules/five.html +38 -17
  92. package/docs/types/five.EventTypes.html +3 -3
  93. package/docs/types/five.LoadResultType.html +1 -0
  94. package/docs/types/five.LooseWork.html +1 -1
  95. package/docs/types/five.LooseWorkInitial.html +1 -1
  96. package/docs/types/five.LooseWorkModel.html +1 -1
  97. package/docs/types/five.LooseWorkObserver.html +1 -1
  98. package/docs/types/five.LooseWorkPanorama.html +1 -1
  99. package/docs/types/five.LooseWorkWithExtrinsics.html +1 -1
  100. package/docs/types/five.Models.html +11 -14
  101. package/docs/types/five.MotionCircle.html +2 -0
  102. package/docs/types/five.MotionConfig.html +1 -0
  103. package/docs/types/five.MotionInitalValue.html +1 -0
  104. package/docs/types/five.PBMAlphaMode.html +1 -0
  105. package/docs/types/five.PBMColorStyle.html +1 -0
  106. package/docs/types/five.PBMFloorStyle.html +1 -0
  107. package/docs/types/five.PBMMeshShaderType.html +1 -0
  108. package/docs/types/five.PBMPointBack.html +1 -0
  109. package/docs/types/five.PBMPointCloudShaderType.html +1 -0
  110. package/docs/types/five.PBMPointShape.html +1 -0
  111. package/docs/types/five.PBMPointSize.html +1 -0
  112. package/docs/types/five.PBMTransition.html +1 -0
  113. package/docs/types/five.ParseWorkOptions.html +1 -1
  114. package/docs/types/five.PostProcessingType.html +1 -1
  115. package/docs/types/five.Tile3dOptions.html +1 -1
  116. package/docs/types/five.TileContentData.html +1 -1
  117. package/docs/types/five.TileDebug.html +1 -0
  118. package/docs/types/five.TileRequestOrder.html +1 -1
  119. package/docs/types/five.TilesetFrameState.html +1 -1
  120. package/docs/types/five.Works.html +1 -1
  121. package/five/index.d.ts +1079 -675
  122. package/five/index.js +208 -154
  123. package/five/index.mjs +9053 -8801
  124. package/gltf-loader/index.js +3 -3
  125. package/gltf-loader/index.mjs +146 -146
  126. package/line/index.js +3 -3
  127. package/line/index.mjs +10 -10
  128. package/package.json +1 -4
  129. package/plugins/index.js +2 -2
  130. package/plugins/index.mjs +2 -2
  131. package/react/index.d.ts +3 -2
  132. package/react/index.js +2 -2
  133. package/react/index.mjs +2 -2
  134. package/shader-lib/index.js +11 -11
  135. package/shader-lib/index.mjs +37 -37
  136. package/sticker/index.js +3 -3
  137. package/sticker/index.mjs +7 -7
  138. package/umd/five-gltf-loader.js +3 -3
  139. package/umd/five-line.js +3 -3
  140. package/umd/five-plugins.js +2 -2
  141. package/umd/five-react.js +2 -2
  142. package/umd/five-shader-lib.js +10 -10
  143. package/umd/five-sticker.js +3 -3
  144. package/umd/five-vfx.js +2 -2
  145. package/umd/five-vue.js +2 -2
  146. package/umd/five.js +208 -154
  147. package/vfx/index.js +2 -2
  148. package/vfx/index.mjs +2 -2
  149. package/vue/index.js +2 -2
  150. package/vue/index.mjs +2 -2
  151. package/work-downloader/index.js +2 -2
  152. package/work-downloader/index.mjs +2 -2
  153. package/docs/classes/five.CustomShader.html +0 -9
  154. package/docs/classes/five.ModelViewLayer.html +0 -17
  155. package/docs/classes/five.TileCubeTextureTarget.html +0 -12
  156. package/docs/interfaces/five.ClipperParameter.html +0 -3
  157. package/docs/interfaces/five.CustomShaderInitArgs.html +0 -6
  158. package/docs/interfaces/five.FragmentShaderChunks.html +0 -5
  159. package/docs/interfaces/five.ModelsEvent.html +0 -6
  160. package/docs/interfaces/five.PBMParameters.html +0 -58
  161. package/docs/interfaces/five.Tile3dLayerOptions.html +0 -31
  162. package/docs/interfaces/five.VertexShaderChunks.html +0 -4
  163. package/docs/types/five.Mirror.html +0 -1
  164. package/docs/types/five.ModelMaterialValues.html +0 -1
  165. package/docs/types/five.ParsedResultType.html +0 -1
  166. package/docs/variables/five.defaultPbmParameters.html +0 -1
  167. package/scripts/five-staticify.js +0 -207
@@ -1,207 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
- const { program } = require("commander");
6
- const archiver = require("archiver");
7
- const ejs = require("ejs");
8
- const { parseWork, defaultImageURLTransform } = require("@realsee/five");
9
-
10
- function matchJsonpFunctionName(url) {
11
- const regExps = [
12
- /\.([0-9a-z]+)\.jsonp([\?\#].*)?$/i,
13
- /jsonp_([0-9a-z]+)([\?\#].*)?$/i
14
- ];
15
- for (const regExp of regExps) {
16
- const matched = url.match(regExp);
17
- if (matched) {
18
- return "jsonp_" + matched[1];
19
- }
20
- }
21
- return null;
22
- };
23
-
24
- async function download(url, jsonpHandleKey) {
25
- const request = /^https\:/.test(url) ? require("https") : require("http");
26
- return new Promise((resolve, reject) => {
27
- const req = request.get(url, res => {
28
- const mime = res.headers['content-type'];
29
- const buffers = [];
30
-
31
- res.on('data', chunk => buffers.push(chunk));
32
- res.on('end', () => {
33
- const contents = Buffer.concat(buffers);
34
- if (jsonpHandleKey) {
35
- const dataURL = `data:${mime};base64,${contents.toString('base64')}`;
36
- const jsopContents = `window[${JSON.stringify(jsonpHandleKey)}] && window[${JSON.stringify(jsonpHandleKey)}](${JSON.stringify(dataURL)})`;
37
- resolve(Buffer.from(jsopContents));
38
- } else {
39
- resolve(Buffer.from(contents));
40
- }
41
- })
42
- res.on("error", () => reject(new Error(`fetch ${url} got error`)));
43
- });
44
- req.on("error", () => reject(new Error(`fetch ${url} got error`)));
45
- })
46
- }
47
-
48
- const template = `
49
- <!DOCTYPE html>
50
- <html lang="en">
51
- <head>
52
- <meta charset="UTF-8">
53
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
54
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
55
- <title>REALSEE PREVIEW</title>
56
- <style>
57
- * { margin: 0; padding: 0; }
58
- html, body { height: 100%; width: 100%; overflow: hidden; }
59
- #app { position: fixed; top: 0; left: 0; right: 0; bottom: 0; overflow: hidden; }
60
- .buttons { position: fixed; top: 10px; left: 10px; pointer-events: none; }
61
- .buttons h3 { margin-top: 10px; text-shadow: 0 0 2px rgba(255, 255, 255, 0.5); }
62
- .buttons button { pointer-events: auto; display: block; font-size: 14px; color: #FFF; background: #5a6268; padding: 3px 10px; border: 1px solid #333; margin-right: 2px; border-radius: 2px; cursor: pointer; margin-top: 10px; }
63
- .buttons button:active { background: #333; }
64
- </style>
65
- <script src="./three.min.js"></script>
66
- <script src="./five.js"></script>
67
- <script>const workJSON = <%- JSON.stringify(work_json) %></script>
68
- </head>
69
- <body>
70
- <!-- 试图渲染容器 -->
71
- <div id="app"></div>
72
- <script>
73
- const five = new FiveSDK.Five();
74
- five.appendTo(document.getElementById("app"));
75
- const work = FiveSDK.parseWork(workJSON, { baseURL: "./", shortPath: <%- JSON.stringify(short_path) %>, jsonp: <%- JSON.stringify(jsonp) %> });
76
- five.load(work);
77
-
78
- const modeButtons = [
79
- { mode: "Panorama", label: "全景漫游模式" },
80
- { mode: "Model", label: "模型漫游模式" },
81
- { mode: "Floorplan", label: "模型纵览模式" },
82
- { mode: "Topview", label: "模型俯视模式" },
83
- { mode: "Mapview", label: "模型自由模式" },
84
- ];
85
-
86
- const buttons = document.createElement("div");
87
- buttons.className = "buttons";
88
- document.body.appendChild(buttons);
89
- buttons.appendChild(document.createElement("h3")).innerHTML = "模式控制";
90
-
91
- // 模态按钮
92
- for (let i = 0; i < modeButtons.length; i++) {
93
- const button = document.createElement("button");
94
- button.innerHTML = modeButtons[i].label;
95
- button.addEventListener('click', () => {
96
- // 通过 changeMode 方法可以切换模态
97
- five.changeMode(FiveSDK.Five.Mode[modeButtons[i].mode]);
98
- });
99
- buttons.appendChild(button);
100
- }
101
- window.addEventListener("resize", () => five.refresh(), false);
102
- </script>
103
- </body>
104
- </html>
105
- `;
106
-
107
- function getThreeJsBuffer() {
108
- let tempPath = path.resolve(__dirname);
109
- while (!(tempPath === '/' || tempPath === ".")) {
110
- const threeFilePath = path.join(tempPath, "node_modules/three/build/three.min.js");
111
- if (fs.existsSync(threeFilePath)) {
112
- return fs.readFileSync(threeFilePath);
113
- }
114
- tempPath = path.dirname(tempPath);
115
- }
116
- throw new Error("three.js is not found");
117
- }
118
-
119
- function getFiveJsBuffer() {
120
- return fs.readFileSync(path.join(__dirname, "../umd/five.js"));
121
- }
122
-
123
- async function staticify(work, output, shortPath = false, jsonp = false, preview = true) {
124
- const zipFilename = /\.zip$/.test(output) ? output : output + ".zip";
125
- const outputStream = fs.createWriteStream(zipFilename);
126
- const archive = archiver("zip", { zlib: { level: 9 } });
127
- archive.on("error", (err) => { throw err; });
128
- outputStream.on("close", function() {
129
- console.info(`zip ${archive.pointer()} total bytes`);
130
- console.info(`dist ${zipFilename}`);
131
- });
132
- archive.pipe(outputStream);
133
-
134
- const resources = [];
135
- const workJSONObject = JSON.parse(fs.readFileSync(work, "utf8"));
136
- parseWork(workJSONObject, {
137
- shortPath,
138
- jsonp,
139
- traverseResource(resource) {
140
- resources.push(resource);
141
- }
142
- });
143
-
144
- const textureCount = resources.filter(({ type }) => type === "texture").length;
145
- let textureSize;
146
- if (textureCount > 50) {
147
- textureSize = 64;
148
- } else if (textureCount > 40) {
149
- textureSize = 128;
150
- } else if (textureCount > 30) {
151
- textureSize = 256;
152
- } else if (textureCount > 15) {
153
- textureSize = 512;
154
- } else if (textureCount > 10) {
155
- textureSize = 1024;
156
- }
157
- if (textureSize) {
158
- for (const resource of resources) {
159
- if (resource.type === "texture") {
160
- resource.origin = defaultImageURLTransform(resource.origin, { size: textureSize, key: resource.type });
161
- }
162
- }
163
- }
164
- for (const { origin, relative } of resources) {
165
- const buffer = await download(origin, matchJsonpFunctionName(relative));
166
- console.info(`${origin} -> ${relative}`);
167
- archive.append(buffer, { name: relative });
168
- }
169
- archive.append(fs.readFileSync(work), { name: "work.json" });
170
-
171
- if (preview) {
172
- archive.append(getFiveJsBuffer(), { name: "five.js" });
173
- archive.append(getThreeJsBuffer(), { name: "three.min.js" });
174
-
175
- const data = {
176
- work_json: workJSONObject,
177
- short_path: Boolean(shortPath),
178
- jsonp: Boolean(jsonp),
179
- };
180
-
181
- const html = typeof preview === 'string' ? ejs.render(fs.readFileSync(preview, "utf8"), data) : ejs.render(template, data);
182
- archive.append(html, { name: "index.html" });
183
- }
184
-
185
- archive.finalize();
186
- }
187
-
188
- program
189
- .requiredOption("--work <work>", "work 的 json 文件")
190
- .requiredOption("--output <output>", "work 静态化的位置")
191
- .option("--shortPath", "简化路径 可选")
192
- .option("--jsonp", "使用jsonp的方式加载文件 可选")
193
- .option("--no-preview", "不生成预览文件")
194
- .option("--template <template>", "html模版文件ejs 参数为 work_json, short_path, jsonp")
195
-
196
- program.parse(process.argv);
197
-
198
- async function main(program) {
199
- let { work, output, shortPath, jsonp, preview, template } = program.opts();
200
- if (preview !== false && template) {
201
- preview = template;
202
- }
203
- await staticify(work, output, shortPath, jsonp, preview);
204
- }
205
-
206
- main(program);
207
-