@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.
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/five.BoxBoundingVolume.html +2 -2
- package/docs/classes/five.Camera.html +7 -7
- package/docs/classes/five.CullingVolume.html +2 -2
- package/docs/classes/five.Five.html +69 -81
- package/docs/classes/five.InternalWebGLRenderer.html +1 -1
- package/docs/classes/five.Model.html +55 -43
- package/docs/classes/five.ModelScene.html +38 -0
- package/docs/classes/five.Motion.html +17 -0
- package/docs/classes/five.PBMContainer.html +4 -12
- package/docs/classes/five.PBMCustomShader.html +11 -0
- package/docs/classes/five.PBMMaterial.html +2 -0
- package/docs/classes/five.PBMMesh.html +2 -4
- package/docs/classes/five.PBMMeshMaterial.html +27 -57
- package/docs/classes/five.PBMPointCloud.html +2 -3
- package/docs/classes/five.PBMPointCloudMaterial.html +15 -51
- package/docs/classes/five.PBMSkinnedMesh.html +2 -3
- package/docs/classes/five.Parameter.html +113 -0
- package/docs/classes/five.RegionBoundingVolume.html +2 -2
- package/docs/classes/five.Scene.html +6 -4
- package/docs/classes/five.SphereBoundingVolume.html +2 -2
- package/docs/classes/five.TextureLoader.html +2 -3
- package/docs/classes/five.Tile.html +2 -2
- package/docs/classes/five.Tile3DModel.html +55 -34
- package/docs/classes/five.TileNode.html +2 -2
- package/docs/classes/five.TileRequestScheduler.html +2 -2
- package/docs/classes/five.Tileset.html +4 -31
- package/docs/classes/five.Trajectory.html +2 -2
- package/docs/classes/five.TrajectoryNode.html +2 -2
- package/docs/classes/five.Work.html +17 -15
- package/docs/classes/gltf_loader.GLTFParser.html +1 -1
- package/docs/classes/sticker.Sticker.html +1 -1
- package/docs/functions/five.loadAt3d.html +1 -1
- package/docs/functions/five.loadB3dm.html +1 -1
- package/docs/functions/five.loadDome.html +1 -1
- package/docs/functions/five.loadDomez.html +1 -1
- package/docs/functions/five.loadFbx.html +1 -1
- package/docs/functions/five.loadGltf.html +1 -1
- package/docs/functions/five.loadPbm.html +1 -1
- package/docs/functions/five.loadPly.html +1 -1
- package/docs/functions/five.loadPnts.html +1 -1
- package/docs/functions/five.loadX3p.html +1 -1
- package/docs/functions/five.parseWork.html +1 -1
- package/docs/functions/react.useFiveCurrentObserver.html +2 -2
- package/docs/functions/react.withFive.html +1 -1
- package/docs/hierarchy.html +1 -1
- package/docs/interfaces/five.BaseEvent.html +1 -1
- package/docs/interfaces/five.BoundingVolume.html +2 -2
- package/docs/interfaces/five.CameraPose.html +2 -2
- package/docs/interfaces/five.EventCallback.html +3 -3
- package/docs/interfaces/five.FiveInitArgs.html +2 -2
- package/docs/interfaces/five.FiveLoadOptions.html +6 -6
- package/docs/interfaces/five.Intersection.html +2 -2
- package/docs/interfaces/five.LoosePanoWork.html +2 -2
- package/docs/interfaces/five.MapviewControllerCustomInitArgs.html +9 -9
- package/docs/interfaces/five.ModelLike.html +3 -0
- package/docs/interfaces/five.ModelSceneEvent.html +6 -0
- package/docs/interfaces/five.PBMClipperParameter.html +3 -0
- package/docs/interfaces/five.PBMCustomShaderInitArgs.html +6 -0
- package/docs/interfaces/five.PBMCustomShaderSlots.html +3 -0
- package/docs/interfaces/five.PBMMeshMaterialParameters.html +29 -0
- package/docs/interfaces/five.PBMPanoDepth.html +9 -0
- package/docs/interfaces/five.PBMPanoPicture.html +9 -7
- package/docs/interfaces/five.PBMPointCloudMaterialParameters.html +27 -0
- package/docs/interfaces/five.PBMRefinedScreen.html +6 -0
- package/docs/interfaces/five.PanoramaControllerCustomInitArgs.html +10 -10
- package/docs/interfaces/five.ParameterMaterialValue.html +71 -0
- package/docs/interfaces/five.ParameterTilesetValue.html +32 -0
- package/docs/interfaces/five.ParameterValue.html +102 -0
- package/docs/interfaces/five.ResolvedParameterValue.html +103 -0
- package/docs/interfaces/five.Tile3DModelLoaderOptions.html +4 -4
- package/docs/interfaces/five.TileCubeNode.html +2 -2
- package/docs/interfaces/five.TileCubeTree.html +2 -2
- package/docs/interfaces/five.TilesetHeader.html +5 -4
- package/docs/interfaces/five.TilesetOptions.html +2 -2
- package/docs/interfaces/five.VRPanoramaControllerCustomInitArgs.html +10 -10
- package/docs/interfaces/five.WorkCubeImage.html +7 -9
- package/docs/interfaces/five.WorkImage.html +10 -12
- package/docs/interfaces/five.WorkInitial.html +8 -8
- package/docs/interfaces/five.WorkModel.html +6 -6
- package/docs/interfaces/five.WorkModelLayer.html +2 -2
- package/docs/interfaces/five.WorkObserver.html +30 -20
- package/docs/interfaces/five.WorkResolvedObserver.html +22 -21
- package/docs/interfaces/five.WorkTile.html +16 -7
- package/docs/interfaces/five.WorkVideo.html +4 -4
- package/docs/interfaces/five.XRPanoramaControllerCustomInitArgs.html +10 -10
- package/docs/interfaces/gltf_loader.DDS.html +2 -2
- package/docs/interfaces/gltf_loader.GLTFReference.html +2 -2
- package/docs/interfaces/react.FiveInjectionTypes.html +9 -8
- package/docs/modules/five.html +38 -17
- package/docs/types/five.EventTypes.html +3 -3
- package/docs/types/five.LoadResultType.html +1 -0
- package/docs/types/five.LooseWork.html +1 -1
- package/docs/types/five.LooseWorkInitial.html +1 -1
- package/docs/types/five.LooseWorkModel.html +1 -1
- package/docs/types/five.LooseWorkObserver.html +1 -1
- package/docs/types/five.LooseWorkPanorama.html +1 -1
- package/docs/types/five.LooseWorkWithExtrinsics.html +1 -1
- package/docs/types/five.Models.html +11 -14
- package/docs/types/five.MotionCircle.html +2 -0
- package/docs/types/five.MotionConfig.html +1 -0
- package/docs/types/five.MotionInitalValue.html +1 -0
- package/docs/types/five.PBMAlphaMode.html +1 -0
- package/docs/types/five.PBMColorStyle.html +1 -0
- package/docs/types/five.PBMFloorStyle.html +1 -0
- package/docs/types/five.PBMMeshShaderType.html +1 -0
- package/docs/types/five.PBMPointBack.html +1 -0
- package/docs/types/five.PBMPointCloudShaderType.html +1 -0
- package/docs/types/five.PBMPointShape.html +1 -0
- package/docs/types/five.PBMPointSize.html +1 -0
- package/docs/types/five.PBMTransition.html +1 -0
- package/docs/types/five.ParseWorkOptions.html +1 -1
- package/docs/types/five.PostProcessingType.html +1 -1
- package/docs/types/five.Tile3dOptions.html +1 -1
- package/docs/types/five.TileContentData.html +1 -1
- package/docs/types/five.TileDebug.html +1 -0
- package/docs/types/five.TileRequestOrder.html +1 -1
- package/docs/types/five.TilesetFrameState.html +1 -1
- package/docs/types/five.Works.html +1 -1
- package/five/index.d.ts +1079 -675
- package/five/index.js +208 -154
- package/five/index.mjs +9053 -8801
- package/gltf-loader/index.js +3 -3
- package/gltf-loader/index.mjs +146 -146
- package/line/index.js +3 -3
- package/line/index.mjs +10 -10
- package/package.json +1 -4
- package/plugins/index.js +2 -2
- package/plugins/index.mjs +2 -2
- package/react/index.d.ts +3 -2
- package/react/index.js +2 -2
- package/react/index.mjs +2 -2
- package/shader-lib/index.js +11 -11
- package/shader-lib/index.mjs +37 -37
- package/sticker/index.js +3 -3
- package/sticker/index.mjs +7 -7
- package/umd/five-gltf-loader.js +3 -3
- package/umd/five-line.js +3 -3
- package/umd/five-plugins.js +2 -2
- package/umd/five-react.js +2 -2
- package/umd/five-shader-lib.js +10 -10
- package/umd/five-sticker.js +3 -3
- package/umd/five-vfx.js +2 -2
- package/umd/five-vue.js +2 -2
- package/umd/five.js +208 -154
- package/vfx/index.js +2 -2
- package/vfx/index.mjs +2 -2
- package/vue/index.js +2 -2
- package/vue/index.mjs +2 -2
- package/work-downloader/index.js +2 -2
- package/work-downloader/index.mjs +2 -2
- package/docs/classes/five.CustomShader.html +0 -9
- package/docs/classes/five.ModelViewLayer.html +0 -17
- package/docs/classes/five.TileCubeTextureTarget.html +0 -12
- package/docs/interfaces/five.ClipperParameter.html +0 -3
- package/docs/interfaces/five.CustomShaderInitArgs.html +0 -6
- package/docs/interfaces/five.FragmentShaderChunks.html +0 -5
- package/docs/interfaces/five.ModelsEvent.html +0 -6
- package/docs/interfaces/five.PBMParameters.html +0 -58
- package/docs/interfaces/five.Tile3dLayerOptions.html +0 -31
- package/docs/interfaces/five.VertexShaderChunks.html +0 -4
- package/docs/types/five.Mirror.html +0 -1
- package/docs/types/five.ModelMaterialValues.html +0 -1
- package/docs/types/five.ParsedResultType.html +0 -1
- package/docs/variables/five.defaultPbmParameters.html +0 -1
- 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
|
-
|