Canwin viewer3DJS
npm install canwinbim-viewer3dnpm
npm install --save canwinbim-viewer3d
`
2. import 导入
`javascript
import Canwin from 'canwinbim-viewer3d'
`
3. viewer 初始化
`
let viewerApp = null;
//配置参数
let options = {
webApi:"120.197.17.151:40007",//webpath
webLocal:"120.197.17.151:40007",//socket
noLoadDocList:true,
clientId:
"366c6088-34e1-4738-b517-649d5575ff58",
clientSecret:
"c2c434b5-60d0-44dd-ab33-6352b5c0998f"
};
//1.通过全局Initializer()初始化(不推荐直接创建Viewer3D)
Canwin.Viewing.Globals.Graphics3DConfig.setGraphicsLib(Canwin.Viewing.Globals.Graphics3DConfig.LIB_XEOKIT_FRAME_JS);
Canwin.Viewing.Initializer(options, function onInitialized() {
//2.通过viewerApp(viewerApp包装了viewer3D)创建一个app
viewerApp = new Canwin.Viewing.ViewingApplication("rendererElement");
//3.注册一个viewer3D
viewerApp.registerViewer(viewerApp.k3d, Canwin.Viewing.Private.BaseViewer3D);
Canwin.Viewing.theExtensionManager.registerExtension(Canwin.Viewing.ExtensionManager.S_NAVIGATION_VIEW_TOOL_EXTENSION, Canwin.Viewing.Globals.NavigationViewToolExtension);
viewerApp.getCurrentViewer().loadExtension(Canwin.Viewing.ExtensionManager.S_NAVIGATION_VIEW_TOOL_EXTENSION);
Canwin.Viewing.theExtensionManager.registerExtension(Canwin.Viewing.ExtensionManager.S_LABEL_MARKER_EXTENSION, Canwin.Viewing.Globals.LabelMarkerExtension);
viewerApp.getCurrentViewer().loadExtension(Canwin.Viewing.ExtensionManager.S_LABEL_MARKER_EXTENSION);
let baseExtension = Canwin.Viewing.theExtensionManager.getExtensionAtId(Canwin.Viewing.ExtensionManager.S_BASE_CONTROL_EXTENSION);
baseExtension.setRotateViewAndScene(1, 0);
baseExtension.enableMoving(false);
});
`
- script 标签引入
1. html 标签引入本地,远程,cdn viewer3d
`javascript
`
2. 初始化
`javascript
let viewerApp = null;
//配置参数
let options = {
webApi:"120.197.17.151:40007",//webpath
webLocal:"120.197.17.151:40007",//socket
noLoadDocList:true,
clientId:
"366c6088-34e1-4738-b517-649d5575ff58",
clientSecret:
"c2c434b5-60d0-44dd-ab33-6352b5c0998f"
};
//1.通过全局Initializer()初始化(不推荐直接创建Viewer3D)
Canwin.Viewing.Globals.Graphics3DConfig.setGraphicsLib(Canwin.Viewing.Globals.Graphics3DConfig.LIB_XEOKIT_FRAME_JS);
Canwin.Viewing.Initializer(options, function onInitialized() {
//2.通过viewerApp(viewerApp包装了viewer3D)创建一个app
viewerApp = new Canwin.Viewing.ViewingApplication("rendererElement");
//3.注册一个viewer3D
viewerApp.registerViewer(viewerApp.k3d, Canwin.Viewing.Private.BaseViewer3D);
Canwin.Viewing.theExtensionManager.registerExtension(Canwin.Viewing.ExtensionManager.S_NAVIGATION_VIEW_TOOL_EXTENSION, Canwin.Viewing.Globals.NavigationViewToolExtension);
viewerApp.getCurrentViewer().loadExtension(Canwin.Viewing.ExtensionManager.S_NAVIGATION_VIEW_TOOL_EXTENSION);
Canwin.Viewing.theExtensionManager.registerExtension(Canwin.Viewing.ExtensionManager.S_LABEL_MARKER_EXTENSION, Canwin.Viewing.Globals.LabelMarkerExtension);
viewerApp.getCurrentViewer().loadExtension(Canwin.Viewing.ExtensionManager.S_LABEL_MARKER_EXTENSION);
let baseExtension = Canwin.Viewing.theExtensionManager.getExtensionAtId(Canwin.Viewing.ExtensionManager.S_BASE_CONTROL_EXTENSION);
baseExtension.setRotateViewAndScene(1, 0);
baseExtension.enableMoving(false);
});
`
- script type=‘’module’ 标签内模块化引用
- 包发布到公网 npm
npm publish`