@realsee/five 5.0.0-alpha.100
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 +362 -0
- package/TERMS.txt +56 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +134 -0
- package/docs/assets/icons.css +1043 -0
- package/docs/assets/icons.png +0 -0
- package/docs/assets/icons@2x.png +0 -0
- package/docs/assets/main.js +52 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1388 -0
- package/docs/assets/widgets.png +0 -0
- package/docs/assets/widgets@2x.png +0 -0
- package/docs/classes/five.AnimationFrameLoop.html +15 -0
- package/docs/classes/five.BVH.html +10 -0
- package/docs/classes/five.BVHIntersect.html +1 -0
- package/docs/classes/five.BVHNode.html +7 -0
- package/docs/classes/five.BVHVector3.html +1 -0
- package/docs/classes/five.Camera.html +11 -0
- package/docs/classes/five.Five.html +303 -0
- package/docs/classes/five.InternalWebGLRenderer.html +1 -0
- package/docs/classes/five.IntersectMesh.html +1 -0
- package/docs/classes/five.LegacyPanoCircleMesh.html +5 -0
- package/docs/classes/five.Model.html +77 -0
- package/docs/classes/five.NetworkSubscribe.html +50 -0
- package/docs/classes/five.PBMContainer.html +17 -0
- package/docs/classes/five.PBMGroup.html +19 -0
- package/docs/classes/five.PBMMaterial.html +15 -0
- package/docs/classes/five.PBMMesh.html +7 -0
- package/docs/classes/five.PanoCircleMesh.html +7 -0
- package/docs/classes/five.Scene.html +3 -0
- package/docs/classes/five.Subscribe.html +56 -0
- package/docs/classes/five.Work.html +30 -0
- package/docs/classes/gltf_loader.GLTFLoader.html +17 -0
- package/docs/classes/gltf_loader.GLTFObject.html +7 -0
- package/docs/classes/line.Line.html +1 -0
- package/docs/classes/line.LineGeometry.html +1 -0
- package/docs/classes/line.LineMaterial.html +1 -0
- package/docs/classes/line.LineSegmentsGeometry.html +1 -0
- package/docs/classes/line.THREE_Line2.html +1 -0
- package/docs/classes/line.THREE_LineSegments2.html +1 -0
- package/docs/classes/react.Store.html +29 -0
- package/docs/classes/server.BVH.html +10 -0
- package/docs/classes/server.BVHIntersect.html +1 -0
- package/docs/classes/server.BVHNode.html +7 -0
- package/docs/classes/server.BVHVector3.html +1 -0
- package/docs/classes/server.Model.html +63 -0
- package/docs/classes/server.PBMGroup.html +9 -0
- package/docs/classes/server.PBMMesh.html +7 -0
- package/docs/classes/sticker.Sticker.html +32 -0
- package/docs/index.html +182 -0
- package/docs/interfaces/five.AddableObject.html +1 -0
- package/docs/interfaces/five.AnimationFrame.html +1 -0
- package/docs/interfaces/five.CameraPose.html +1 -0
- package/docs/interfaces/five.DepthPanoramaControllerCustomInitArgs.html +28 -0
- package/docs/interfaces/five.EventCallback.html +391 -0
- package/docs/interfaces/five.FiveInitArgs.html +96 -0
- package/docs/interfaces/five.FloorplanControllerCustomInitArgs.html +15 -0
- package/docs/interfaces/five.ImageOptions.html +16 -0
- package/docs/interfaces/five.ImageURLOptions.html +1 -0
- package/docs/interfaces/five.IntersectMeshInterface.html +3 -0
- package/docs/interfaces/five.Intersection.html +7 -0
- package/docs/interfaces/five.ModelControllerCustomInitArgs.html +20 -0
- package/docs/interfaces/five.ModelEventCallback.html +22 -0
- package/docs/interfaces/five.MovePanoOptions.html +39 -0
- package/docs/interfaces/five.PBMPanoPicture.html +7 -0
- package/docs/interfaces/five.PBMParameters.html +15 -0
- package/docs/interfaces/five.PanoCircleMeshInterface.html +19 -0
- package/docs/interfaces/five.PanoramaControllerCustomInitArgs.html +28 -0
- package/docs/interfaces/five.PanoramaLikeControllerCustomInitArgs.html +20 -0
- package/docs/interfaces/five.Pose.html +35 -0
- package/docs/interfaces/five.Scissor.html +14 -0
- package/docs/interfaces/five.State.html +19 -0
- package/docs/interfaces/five.SubscribeMixinType.emit.html +1 -0
- package/docs/interfaces/five.SubscribeMixinType.hasListener.html +1 -0
- package/docs/interfaces/five.SubscribeMixinType.off.html +1 -0
- package/docs/interfaces/five.SubscribeMixinType.on.html +1 -0
- package/docs/interfaces/five.SubscribeMixinType.once.html +1 -0
- package/docs/interfaces/five.TextureOptions.html +18 -0
- package/docs/interfaces/five.TopviewControllerCustomInitArgs.html +7 -0
- package/docs/interfaces/five.VRPanoramaControllerCustomInitArgs.html +24 -0
- package/docs/interfaces/five.WorkCubeImage.html +13 -0
- package/docs/interfaces/five.WorkImage.html +21 -0
- package/docs/interfaces/five.WorkInitial.html +13 -0
- package/docs/interfaces/five.WorkModel.html +11 -0
- package/docs/interfaces/five.WorkObserver.html +25 -0
- package/docs/interfaces/five.WorkTile.html +1 -0
- package/docs/interfaces/five.WorkVideo.html +9 -0
- package/docs/interfaces/gltf_loader.GLTF.html +7 -0
- package/docs/interfaces/react.FiveActionReactCallbacks.html +62 -0
- package/docs/interfaces/react.FiveInjectionTypes.html +191 -0
- package/docs/interfaces/react.PropTypeOfFiveFeatures.html +1 -0
- package/docs/interfaces/server.Intersection.html +7 -0
- package/docs/interfaces/server.ModelEventCallback.html +18 -0
- package/docs/interfaces/sticker.IntersectionLike.html +8 -0
- package/docs/media/coordinate.jpg +0 -0
- package/docs/media/topview.jpg +0 -0
- package/docs/media/typescript.jpg +0 -0
- package/docs/modules/five.SubscribeMixinType.html +1 -0
- package/docs/modules/five.html +481 -0
- package/docs/modules/gltf_loader.html +1 -0
- package/docs/modules/line.html +1 -0
- package/docs/modules/react.html +130 -0
- package/docs/modules/server.html +18 -0
- package/docs/modules/sticker.html +1 -0
- package/docs/modules.html +1 -0
- package/exporters/staticify.js +203 -0
- package/five/index.d.ts +2061 -0
- package/five/index.js +372 -0
- package/gltf-loader/index.d.ts +75 -0
- package/gltf-loader/index.js +260 -0
- package/line/index.d.ts +68 -0
- package/line/index.js +260 -0
- package/package.json +36 -0
- package/react/index.d.ts +812 -0
- package/react/index.js +260 -0
- package/resource/basis/basis_transcoder.js +22 -0
- package/resource/basis/basis_transcoder.wasm +0 -0
- package/resource/gltf/draco_decoder.js +31 -0
- package/resource/gltf/draco_decoder.wasm +0 -0
- package/resource/gltf/draco_wasm_wrapper.js +119 -0
- package/scripts/five-plugin-init.js +83 -0
- package/scripts/five-quick-start-init.js +80 -0
- package/scripts/five-react-component-init.js +83 -0
- package/scripts/five-staticify.js +21 -0
- package/server/index.d.ts +568 -0
- package/server/index.js +367 -0
- package/sticker/index.d.ts +70 -0
- package/sticker/index.js +260 -0
- package/templates/plugin/README.md +38 -0
- package/templates/plugin/devtools/external-five.js +5 -0
- package/templates/plugin/devtools/external-three.js +5 -0
- package/templates/plugin/devtools/tsconfig.build.json +18 -0
- package/templates/plugin/devtools/webpack.bundle.js +44 -0
- package/templates/plugin/devtools/webpack.example.js +39 -0
- package/templates/plugin/docs/.gitkeep +0 -0
- package/templates/plugin/examples/data.json +507 -0
- package/templates/plugin/examples/index.html +28 -0
- package/templates/plugin/examples/index.ts +12 -0
- package/templates/plugin/lib/index.ts +30 -0
- package/templates/plugin/package.json +32 -0
- package/templates/plugin/tsconfig.json +26 -0
- package/templates/quick-start/README.md +47 -0
- package/templates/quick-start/assets/work.json +507 -0
- package/templates/quick-start/index.html +54 -0
- package/templates/quick-start/index.tsx +123 -0
- package/templates/quick-start/package.json +25 -0
- package/templates/quick-start/tsconfig.json +27 -0
- package/templates/quick-start/webpack.config.js +45 -0
- package/templates/quick-start/webpack.production.js +42 -0
- package/templates/react-component/README.md +32 -0
- package/templates/react-component/devtools/external-five.js +5 -0
- package/templates/react-component/devtools/external-react.js +5 -0
- package/templates/react-component/devtools/external-three.js +5 -0
- package/templates/react-component/devtools/tsconfig.build.json +19 -0
- package/templates/react-component/devtools/webpack.bundle.js +44 -0
- package/templates/react-component/devtools/webpack.example.js +39 -0
- package/templates/react-component/docs/.gitkeep +0 -0
- package/templates/react-component/examples/data.json +507 -0
- package/templates/react-component/examples/index.html +17 -0
- package/templates/react-component/examples/index.tsx +62 -0
- package/templates/react-component/lib/index.tsx +157 -0
- package/templates/react-component/package.json +38 -0
- package/templates/react-component/tsconfig.json +27 -0
- package/umd/five-gltf-loader.js +2 -0
- package/umd/five-gltf-loader.js.LICENSE.txt +14 -0
- package/umd/five-line.js +2 -0
- package/umd/five-line.js.LICENSE.txt +14 -0
- package/umd/five-react.js +2 -0
- package/umd/five-react.js.LICENSE.txt +14 -0
- package/umd/five-sticker.js +2 -0
- package/umd/five-sticker.js.LICENSE.txt +14 -0
- package/umd/five.js +2 -0
- package/umd/five.js.LICENSE.txt +116 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import * as ReactDOM from "react-dom";
|
|
4
|
+
import { Five, Mode, State, Work, parseWork } from "@realsee/five";
|
|
5
|
+
import {
|
|
6
|
+
createFiveProvider,
|
|
7
|
+
FiveCanvas,
|
|
8
|
+
useFiveCurrentState,
|
|
9
|
+
useFiveWork
|
|
10
|
+
} from "@realsee/five/react";
|
|
11
|
+
|
|
12
|
+
const FiveProvider = createFiveProvider({
|
|
13
|
+
imageOptions: { size: 1024 },
|
|
14
|
+
onlyRenderIfNeeds: true,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const Viewport: React.FC = () => {
|
|
18
|
+
return <div className="viewport">
|
|
19
|
+
<FiveCanvas width={512} height={512}></FiveCanvas>
|
|
20
|
+
</div>
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const Controller: React.FC = () => {
|
|
24
|
+
return <div className="controller">
|
|
25
|
+
<h1>Five Quick Start</h1>
|
|
26
|
+
<ModeChangePanel/>
|
|
27
|
+
<CameraPanel/>
|
|
28
|
+
<PanoPanel/>
|
|
29
|
+
</div>
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const MODE_LABELS: Partial<Record<Mode, string>> = {
|
|
33
|
+
[Five.Mode.Panorama]: "全景游走模式",
|
|
34
|
+
[Five.Mode.Floorplan]: "模型总览模式",
|
|
35
|
+
[Five.Mode.Topview]: "户型图模式",
|
|
36
|
+
[Five.Mode.Model]: "模型游走模式",
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const ModeChangePanel: React.FC = () => {
|
|
40
|
+
|
|
41
|
+
const [state, setState] = useFiveCurrentState();
|
|
42
|
+
|
|
43
|
+
const changeMode = React.useCallback((mode: Mode) => setState({ mode }), []);
|
|
44
|
+
return <div className="panel">
|
|
45
|
+
<div className="label">模态切换:</div>
|
|
46
|
+
<div className="content">
|
|
47
|
+
<div>{MODE_LABELS[state.mode]}</div>
|
|
48
|
+
<div>
|
|
49
|
+
<button onClick={() => changeMode(Five.Mode.Panorama)}>{MODE_LABELS[Five.Mode.Panorama]}</button>
|
|
50
|
+
<button onClick={() => changeMode(Five.Mode.Floorplan)}>{MODE_LABELS[Five.Mode.Floorplan]}</button>
|
|
51
|
+
<button onClick={() => changeMode(Five.Mode.Topview)}>{MODE_LABELS[Five.Mode.Topview]}</button>
|
|
52
|
+
<button onClick={() => changeMode(Five.Mode.Model)}>{MODE_LABELS[Five.Mode.Model]}</button>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const CameraPanel: React.FC = () => {
|
|
59
|
+
const [state, setState] = useFiveCurrentState();
|
|
60
|
+
return <div className="panel">
|
|
61
|
+
<div className="label">相机控制:</div>
|
|
62
|
+
<div className="content">
|
|
63
|
+
<div>
|
|
64
|
+
水平角: {state.longitude.toFixed(2)}(弧度)
|
|
65
|
+
</div>
|
|
66
|
+
<div>
|
|
67
|
+
俯仰角: {state.latitude.toFixed(2)}(弧度)
|
|
68
|
+
</div>
|
|
69
|
+
<div>
|
|
70
|
+
可视角度: {state.fov.toFixed(0)}(角度)
|
|
71
|
+
</div>
|
|
72
|
+
<div>
|
|
73
|
+
<button onMouseDown={() => setState({ longitude: state.longitude + 0.01 })}>向左</button>
|
|
74
|
+
<button onMouseDown={() => setState({ latitude: state.latitude - 0.01 })}>向上</button>
|
|
75
|
+
<button onMouseDown={() => setState({ latitude: state.latitude + 0.01 })}>向下</button>
|
|
76
|
+
<button onMouseDown={() => setState({ longitude: state.longitude - 0.01 })}>向右</button>
|
|
77
|
+
<button onMouseDown={() => setState({ fov: state.fov + 1 })}>可视角度+</button>
|
|
78
|
+
<button onMouseDown={() => setState({ fov: state.fov - 1 })}>可视角度-</button>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const PanoPanel: React.FC = () => {
|
|
85
|
+
const [ work ] = useFiveWork();
|
|
86
|
+
const [currentState, setState] = useFiveCurrentState();
|
|
87
|
+
const [panos, setPanos] = React.useState<State[]>(() => [currentState]);
|
|
88
|
+
return <div className="panel">
|
|
89
|
+
<div className="label">存储快照:</div>
|
|
90
|
+
<div className="content">
|
|
91
|
+
{panos.map((state, index) => {
|
|
92
|
+
return <button key={index} onClick={() => setState(state)}>快照{index + 1}</button>
|
|
93
|
+
})}
|
|
94
|
+
<button onClick={() => setPanos(panos.concat(currentState))}>+</button>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const App: React.FC = () => {
|
|
100
|
+
|
|
101
|
+
const [work, setWork] = React.useState<Work>();
|
|
102
|
+
|
|
103
|
+
const loadWork = React.useCallback((url: string) => {
|
|
104
|
+
fetch(url)
|
|
105
|
+
.then(res => res.json())
|
|
106
|
+
.then(data => setWork(parseWork(data)));
|
|
107
|
+
}, []);
|
|
108
|
+
|
|
109
|
+
React.useEffect(() => {
|
|
110
|
+
loadWork("./assets/work.json");
|
|
111
|
+
}, []);
|
|
112
|
+
|
|
113
|
+
if (work) {
|
|
114
|
+
return <FiveProvider initialWork={work} ref={ref => Object.assign(window, { five: ref?.five })}>
|
|
115
|
+
<div className="layout">
|
|
116
|
+
<Viewport/><Controller/>
|
|
117
|
+
</div>
|
|
118
|
+
</FiveProvider>
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
ReactDOM.render(<App></App>, document.getElementById("app"));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "five-quick-start",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "five quick start",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "webpack serve",
|
|
7
|
+
"build": "webpack --config ./webpack.production.js"
|
|
8
|
+
},
|
|
9
|
+
"private": true,
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@types/react": "^17.0.14",
|
|
12
|
+
"@types/react-dom": "^17.0.9",
|
|
13
|
+
"copy-webpack-plugin": "^9.0.1",
|
|
14
|
+
"html-webpack-plugin": "^5.3.2",
|
|
15
|
+
"http-server": "^0.12.1",
|
|
16
|
+
"react": "^17.0.2",
|
|
17
|
+
"react-dom": "^17.0.2",
|
|
18
|
+
"three": "^0.117.1",
|
|
19
|
+
"ts-loader": "^9.1.1",
|
|
20
|
+
"typescript": "^4.4.2",
|
|
21
|
+
"webpack": "^5.35.1",
|
|
22
|
+
"webpack-cli": "^4.6.0",
|
|
23
|
+
"webpack-dev-server": "^3.11.2"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Basic Options */
|
|
4
|
+
"jsx": "react",
|
|
5
|
+
"target": "ES5",
|
|
6
|
+
"lib": ["ES5", "DOM"],
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"rootDir": "./",
|
|
10
|
+
|
|
11
|
+
/* Strict Type-Checking Options */
|
|
12
|
+
"strict": true,
|
|
13
|
+
"noImplicitAny": true,
|
|
14
|
+
"strictNullChecks": true,
|
|
15
|
+
"declarationMap": false,
|
|
16
|
+
|
|
17
|
+
/* Module Resolution Options */
|
|
18
|
+
"moduleResolution": "node",
|
|
19
|
+
"baseUrl": "./",
|
|
20
|
+
"esModuleInterop": true,
|
|
21
|
+
"preserveSymlinks": true,
|
|
22
|
+
|
|
23
|
+
/* Experimental Options */
|
|
24
|
+
"experimentalDecorators": true,
|
|
25
|
+
"emitDecoratorMetadata": true
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
3
|
+
const express = require('express');
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
context: __dirname,
|
|
7
|
+
entry: "./index.tsx",
|
|
8
|
+
output: {
|
|
9
|
+
path: path.resolve(__dirname, "../dist"),
|
|
10
|
+
filename: "index.bundle.js"
|
|
11
|
+
},
|
|
12
|
+
mode: "development",
|
|
13
|
+
devtool: "eval-cheap-source-map",
|
|
14
|
+
devServer: {
|
|
15
|
+
port: 3000,
|
|
16
|
+
contentBase: path.resolve(__dirname, "../dist"),
|
|
17
|
+
before(app) {
|
|
18
|
+
app.use('/assets/', express.static(path.resolve(__dirname, 'assets')));
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
module: {
|
|
22
|
+
rules: [{
|
|
23
|
+
test: /\.tsx?$/i,
|
|
24
|
+
exclude: /node_modules/,
|
|
25
|
+
use: [{
|
|
26
|
+
loader: "ts-loader",
|
|
27
|
+
options: {
|
|
28
|
+
compilerOptions: {
|
|
29
|
+
"declaration": false,
|
|
30
|
+
"sourceMap": true,
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
}]
|
|
34
|
+
}]
|
|
35
|
+
},
|
|
36
|
+
plugins: [
|
|
37
|
+
new HtmlWebpackPlugin({
|
|
38
|
+
template: path.resolve(__dirname, 'index.html'),
|
|
39
|
+
filename: "index.html",
|
|
40
|
+
}),
|
|
41
|
+
],
|
|
42
|
+
resolve: {
|
|
43
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".json"],
|
|
44
|
+
}
|
|
45
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
3
|
+
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
context: __dirname,
|
|
7
|
+
entry: "./index.tsx",
|
|
8
|
+
output: {
|
|
9
|
+
path: path.resolve(__dirname, "dist"),
|
|
10
|
+
filename: "index.bundle.js"
|
|
11
|
+
},
|
|
12
|
+
mode: "production",
|
|
13
|
+
module: {
|
|
14
|
+
rules: [{
|
|
15
|
+
test: /\.tsx?$/i,
|
|
16
|
+
exclude: /node_modules/,
|
|
17
|
+
use: [{
|
|
18
|
+
loader: "ts-loader",
|
|
19
|
+
options: {
|
|
20
|
+
compilerOptions: {
|
|
21
|
+
"declaration": false,
|
|
22
|
+
"sourceMap": true,
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
}]
|
|
26
|
+
}]
|
|
27
|
+
},
|
|
28
|
+
plugins: [
|
|
29
|
+
new CopyWebpackPlugin({
|
|
30
|
+
patterns: [
|
|
31
|
+
{ from: "assets", to: "assets" }
|
|
32
|
+
]
|
|
33
|
+
}),
|
|
34
|
+
new HtmlWebpackPlugin({
|
|
35
|
+
template: path.resolve(__dirname, "index.html"),
|
|
36
|
+
filename: "index.html",
|
|
37
|
+
})
|
|
38
|
+
],
|
|
39
|
+
resolve: {
|
|
40
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".json"]
|
|
41
|
+
}
|
|
42
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Five 插件: a-five-react-component
|
|
2
|
+
|
|
3
|
+
> 这是一个 Five 的 React 组件。
|
|
4
|
+
> 这个组件的用途是什么。
|
|
5
|
+
> 能干什么。为什么要使用这组件。
|
|
6
|
+
|
|
7
|
+
## 参数
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
type PropTypes = {
|
|
11
|
+
parameter1: number,
|
|
12
|
+
parameter2: string,
|
|
13
|
+
children: JSX.Element,
|
|
14
|
+
};
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 如何使用
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { AFiveReactComponent } from "a-five-react-component";
|
|
21
|
+
|
|
22
|
+
<FiveProvider>
|
|
23
|
+
<FiveCanvas width={512} height={512}></FiveCanvas>
|
|
24
|
+
|
|
25
|
+
{/* 使用 AFiveReactComponent */}
|
|
26
|
+
<AFiveReactComponent parameter1={123} parameter2={"abc"}>
|
|
27
|
+
<div>Hello World!</div>
|
|
28
|
+
</AFiveReactComponent>
|
|
29
|
+
|
|
30
|
+
</StoreProvider>;
|
|
31
|
+
|
|
32
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": [
|
|
3
|
+
"../lib/**/*.ts"
|
|
4
|
+
],
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"jsx": "react",
|
|
7
|
+
"target": "ES5",
|
|
8
|
+
"module": "CommonJS",
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"allowSyntheticDefaultImports": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"moduleResolution": "node",
|
|
13
|
+
"sourceMap": true,
|
|
14
|
+
"allowJs": true,
|
|
15
|
+
"rootDir": "../lib",
|
|
16
|
+
"outDir": "../build",
|
|
17
|
+
"skipLibCheck": true
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const { NormalModuleReplacementPlugin } = require("webpack");
|
|
3
|
+
|
|
4
|
+
const name = require("../package.json").name.split("/").pop();
|
|
5
|
+
const libraryName = name.replace(/(^|\-)\w/g, char => char[char.length - 1].toUpperCase());
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
context: path.join(__dirname, "lib"),
|
|
9
|
+
entry: {
|
|
10
|
+
[name]: path.join(__dirname, '../lib/index.tsx'),
|
|
11
|
+
},
|
|
12
|
+
output: {
|
|
13
|
+
path: path.join(__dirname, "../bundles"),
|
|
14
|
+
filename: "[name].js",
|
|
15
|
+
library: libraryName,
|
|
16
|
+
libraryTarget: "umd",
|
|
17
|
+
libraryExport: libraryName
|
|
18
|
+
},
|
|
19
|
+
mode: "production",
|
|
20
|
+
devtool: "source-map",
|
|
21
|
+
module: {
|
|
22
|
+
rules: [{
|
|
23
|
+
test: /\.tsx?$/i,
|
|
24
|
+
exclude: /node_modules/,
|
|
25
|
+
use: [{
|
|
26
|
+
loader: "ts-loader",
|
|
27
|
+
options: {
|
|
28
|
+
configFile: path.join(__dirname, "tsconfig.build.json"),
|
|
29
|
+
compilerOptions: {
|
|
30
|
+
"declaration": false,
|
|
31
|
+
"sourceMap": true,
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
}]
|
|
35
|
+
}],
|
|
36
|
+
},
|
|
37
|
+
plugins: [
|
|
38
|
+
new NormalModuleReplacementPlugin(/^three$/, path.join(__dirname, 'external-three.js')),
|
|
39
|
+
new NormalModuleReplacementPlugin(/^\@realsee\/five$/, path.join(__dirname, 'external-five.js')),
|
|
40
|
+
],
|
|
41
|
+
resolve: {
|
|
42
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".json"],
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const glob = require("glob");
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
context: path.join(__dirname, "../examples"),
|
|
6
|
+
entry: () => {
|
|
7
|
+
const list = glob.sync("**/index.ts?(x)", { cwd: path.join(__dirname, "../examples") });
|
|
8
|
+
const entry = {}
|
|
9
|
+
list.map(filename => {
|
|
10
|
+
const name = filename.replace(/\.tsx?$/i, '');
|
|
11
|
+
entry[name] = './' + filename;
|
|
12
|
+
})
|
|
13
|
+
return entry;
|
|
14
|
+
},
|
|
15
|
+
output: {
|
|
16
|
+
path: path.join(__dirname, "../examples"),
|
|
17
|
+
filename: "[name].bundle.js"
|
|
18
|
+
},
|
|
19
|
+
mode: "development",
|
|
20
|
+
devtool: "eval-cheap-source-map",
|
|
21
|
+
module: {
|
|
22
|
+
rules: [{
|
|
23
|
+
test: /\.tsx?$/i,
|
|
24
|
+
exclude: /node_modules/,
|
|
25
|
+
use: [{
|
|
26
|
+
loader: "ts-loader",
|
|
27
|
+
options: {
|
|
28
|
+
compilerOptions: {
|
|
29
|
+
"declaration": false,
|
|
30
|
+
"sourceMap": true,
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
}]
|
|
34
|
+
}]
|
|
35
|
+
},
|
|
36
|
+
resolve: {
|
|
37
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".json"],
|
|
38
|
+
}
|
|
39
|
+
};
|
|
File without changes
|