@ts3d-hoops/web-viewer
-
@ts3d-hoops/web-viewer HOOPS Visualize Web WebViewer
HOOPS Visualize Web can be imported in different ways.
All of our libraries are formatted as npm packages in the
@ts3d-hoopsfolder.In an effort to modernize and improve our codebase, we’ve dedicated our best efforts to migrate it to use ES Modules and simplify integration for users of such systems.
As an alternative, the SDK is also available as IIFE and UMD.
The ESM with npm (Recommended)
You can install the web-viewer package with npm and the install from a local path feature:
npm install path/to/@ts3d-hoops/web-viewer
We recommend placing the
@ts3d-hoopsfolder under your web application project root folder due to an npm limitation. Alternatively, you can use Yarn. If not, sub-dependencies ofweb-viewerwill not be linked in yournode_modules.The
engine.esm.wasmfile required by the web-viewer is located in the@ts3d-hoops/sc-enginefolder. You may need to copy it to your public directory or use a framework-specific plugin to embed it in your application. Don’t forget to update theenginePathattribute if needed.Then, use our packages like any npm package in your code:
<!doctype html> <html lang="en"> <head> <!-- ... --> </head> <body> <!-- ... --> <div id="viewerContainer" tabindex="0"></div> <!-- ... --> <script type="module" crossorigin src="main.js"></script> </body> </html>
import { WebViewer } from '@ts3d-hoops/hoops-web'; const container = document.getElementById('viewerContainer'); const hwv = new WebViewer({ container, endpointUri: 'models/microengine.scs', });
The IIFE (Historical)
Historically, we have always provided the web viewer code as an IIFE (Immediately Invoked Function Expression), and we will continue to do so.
Required files:
engine.esm.wasm hoops-web-viewer.iife.js
Your HTML should look like the following simple example:
<!doctype html> <html lang="en"> <head> <!-- ... --> <script type="text/javascript" src="./hoops-web-viewer.iife.js"></script> </head> <body> <!-- ... --> <div id="viewerContainer" tabindex="0"></div> <!-- ... --> <script type="text/javascript"> const container = document.getElementById('viewerContainer'); const hwv = new Communicator.WebViewer({ container, endpointUri: 'models/microengine.scs', }); /* ... */ </script> </body> </html>
You can see an example of using the IIFE in the samples as well.
The UMD
Additionally, some users may use systems based on RequireJS and rely on AMD/UMD files.
In an attempt to provide the easiest to use SDK and facilitate integration in any environment
engine.esm.wasm hoops-web-viewer.umd.js
The code should be very similar to what you’re used to:
<!doctype html> <html lang="en"> <head> <!-- ... --> <script crossorigin src="./require.min.js"></script> </head> <body> <!-- ... --> <div id="viewerContainer" tabindex="0"></div> <!-- ... --> <script type="module"> requirejs(['hoops-web-viewer.umd.js'], (Communicator) => { const hwv = new Communicator.WebViewer({ container, endpointUri: 'models/microengine.scs', }); /* ... */ }); </script> </body> </html>
An example is available in the samples.
Using TypeScript
Type declaration files are directly embedded in the npm packages.
ESM users can use
web_viewer/hoops-web-viewer.d.tsand add it to their project either in theirtsconfig.jsonor as a reference tag in their TypeScript files:/// <reference path="path/to/hoops-web-viewer.d.ts" />We recommend our TypeScript users to consider using ESM in a TypeScript project. If you opt for IIFE or UMD, you can use
web_viewer/hoops-web-viewer.iife.d.tsorweb_viewer/hoops-web-viewer.umd.d.ts.Using the Monolith
It may be cumbersome to set the path to
engine.esm.wasmin your project, and your bundler may complain about it, especially in development mode (bundlers generally do not like dynamic imports). To make your integration experience smoother, you can use one of the variants of our viewer code that corresponds to your import scheme (ESM, UMD, or IIFE) and contains the term “monolith” in its name (e.g.,hoops-web-viewer-monolith.mjs,hoops-web-viewer-monolith.umd.js, orhoops-web-viewer-monolith.iife.js). This allows you to completely avoid handlingengine.esm.wasmin your configuration.If you are using an npm-based approach, you can also benefit from the monolith feature. The first thing to do is to install the related package:
npm install path/to/@ts3d-hoops/web-viewer-monolith
Finally, you will need to add these lines in your product prior to calling the WebViewer constructor:
import '@ts3d-hoops/web-viewer-monolith';
Everything should work as expected.
Using the monolith may result in a larger file size because the engine binary is stored directly in the code as a base64 string rather than as an external binary file. On the other hand, the extra data is embedded within the code, so fewer files need to be queried via HTTP requests.Index
References
Enumerations
AntiAliasingModeAttributeTypeAxisBasicUnitBlurIntervalUnitBoundingPreviewModeBranchVisibilityBuiltinOverlayIndexButtonButtonsCullingVectorSpaceDepthRangeDrawModeDrawStrategyElementTypeEventTypeFaceWindingFileTypeFilterIdFloorplanOrientationHandleEventTypeHandleTypeImageFormatInfoTypeInstanceModifierKeyCodeKeyInputTypeKeyModifiersLayerIdLinePatternLengthUnitMeshInstanceCreationFlagsMouseInputTypeNodeSourceNodeTypeOperatorIdOrbitFallbackModeOverlayAnchorOverlayUnitPmiSubTypePmiTopoRefPmiTypePointShapePointSizeUnitProjectionRelationshipTypeRendererTypeScreenConfigurationSelectionHighlightModeSelectionMaskSelectionModeSelectionTypeSimpleReflectionAttenuationUnitSnapshotLayerStreamingModeTextureModifierTextureParameterizationTextureTilingTouchInputTypeTransparencyModeTreeWalkModeViewOrientationWalkDirectionWalkModeXRayGroup
Classes
AssemblyDataParseErrorAxisTriadBoxCameraColorCommunicatorErrorCuttingManagerCuttingPlaneCuttingSectionDirectionalLightExplodeManagerFaceFaceDistanceItemFaceMeshDataFilteredNodesIncrementalPickConfigInternalLogicErrorInvalidIndexErrorInvalidNodeIdErrorInvalidNodeTypeErrorLightLineManagerLoadCancelledErrorLoadErrorLoadSubtreeConfigMarkupManagerMarkupTypeManagerMatrixMeasureManagerMeshDataMeshInstanceDataMissingModelErrorModelNavCubeOperatorManagerParseErrorPickConfigPickOutsideCanvasErrorPlanePoint2Point3Point4PointLightPointMeshDataPolylineMeshDataRayRefOnTopoItemSelectionInvalidatedErrorSheetManagerSnapshotConfigSubentityAttributesSvgConfigVerticalGradientViewViewAxesVisibilityStateWebViewerXmlParseError
Interfaces
AttributeBloomLayerInfoCallbackMapComparisonConfigCullingVectorCuttingPlaneDataFaceFaceDistanceObjectGetNodesBoundingConfigGroundPlaneIAssemblyTreeIBoxICallbackManagerIColorICuttingManagerICuttingSectionIdBooleanMapIdColorMapIdNumberMapIdStringMapImageBasedLightingOrientationImageOptionsIMaterialIModelIModelStructureIPoint2IPoint3IPoint4IRayIScEngineIViewIWebViewerMarkupDataMeshDataCopyMeshDataCopyElementMeshDataCopyElementGroupMeshDataCopyIteratorMeshDataCopyVertexMetallicRoughnessValueObjectConstructorRelationshipInfoSimpleReflectionAttenuationStringStringMapTextureOptionsUnitElementViewConfigWebViewerConfig
Type Aliases
BimIdBodyIdBuiltInOperatorIdCadViewIdDegreesExchangeIdExternalModelNameFilterNameGenericIdGenericTypeHtmlIdImageIdLayerNameLightKeyLinePatternMassageModelNameFuncMaterialParamMatrix12Matrix16Matrix9MeshIdModelNameToScsFileFuncNodeDrawModeNodeIdNodeIdOffsetPartIdPixelsPmiIdRadiansRgbasScsUriSheetIdUserDataIndexUuidUvsVector3Vector3sVector4Vector4sXmlFilenameXRayTransparencyMode
Variables
DefaultTransitionDurationEmptyModelNameInvalidNodeIdNoOverrideDrawModeOhmSubscript1Subscript2Subscript3SubscriptNeg
Functions
closestPointFromPointToSegmentclosestPointScalarFromPointToSegmentcomputeAngleBetweenVectorcomputeOffaxisRotationcomputePointToLineDistancecreateUuiddegreesToRadiansdistanceLineLineformatWithUnitgenerateArcPointsgeneratePointsOnCircleget3dBaseFromVectorgetLongUnitStringgetOrthogonalVectorintersect3d2PlanesintersectionPlaneLineintersectionPlaneLine2isIColorisIPoint2isIPoint3isIPoint4isPointInRect2disPointOnLineSegmentisPointOnLineSegment2dlineLineIntersectoneVectorCrossradiansToDegreessortVerticesCounterClockwise
References
-
BimMask - BimMask ->
Sc.BimMask
-
Milliseconds - Milliseconds ->
Sc.Milliseconds
-
OverlayId - OverlayId ->
Sc.OverlayIdType used to denote overlay indices.
-
OverlayIndex - OverlayIndex ->
Sc.OverlayIndexType used to denote overlay indices.
-
ScModelName - ScModelName ->
Sc.ScModelName
-
ScsBuffer - ScsBuffer ->
Sc.ScsBuffer
-
TextureFlags - TextureFlags ->
Sc.TextureFlags
-
ViewKey - ViewKey ->
Sc.ViewKey