@3ddv/dvm

中文文档
2.8.5发布于 2026/06/03MITTypeScriptESM + CJS零依赖近 30 天下载 1.8万

This package is a helper to use DVM. Instead of just adding the script to your website, you can use this package to:

原始使用文档
文档目录5 节
  1. Installation
  2. How to use it
  3. Feature detection and modern build
  4. Builtin versions
  5. Specific versions

README

This package is a helper to use DVM. Instead of just adding the script to your website, you can use this package to:

  • Use ES6 import/export syntax.
  • Get Typescript definitions.

Using this package will still continue to download the core DVM from our CDN, adding it to your website.

If you use this package, you must not add manually the dvm.js script in your html.

Installation

npm install --save @3ddv/dvm

How to use it

This package exports the following functions:

  • loadModule: equivalent to DVM.loadModule.
  • allowFeatureDetection: true by default. false if you want to disable feature detection entirely. You have to call it before loading any module. Check more information here.
  • useModernBuild: false by default. true if you want to load directly ES2020+ modules without checking any feature detection. You have to call it before loading any module. Check more information here.
  • setDVMVersion: You can specify from which namespace you want to download DVM. By default, it will be downloaded from stable. It has to be called before the first loadModule call. You should leave it by default unless we specify something else. This would be the equivalent to include the specific script.
  • setDefaultModuleVersion: You can specify the default version branch for a specific module. By default, all modules uses stable branch.
  • setDefaultEnvironment: Switch the CDN environment from which DVM is downloaded. Defaults to "pro".
  • getBuiltinDVMVersion: Returns the builtin version of DVM.
  • getBuiltinModuleVersion: Returns the builtin version of a module.
  • getDefaultModuleVersion: Returns the currently configured default branch for a module.

loadModule also accepts the following per-call options that override the global defaults:

  • version — branch (e.g. "stable", "latest") or numeric version (e.g. "2.5.6") for this call.
  • feature_detection: false — disable feature detection just for this call.
  • modern: true — request the ES2020+ build of the module for this call.
  • polyfills — load the polyfills chunk. Defaults to true for ES5 builds and false for ES2020+ builds; set explicitly to override.
  • plugins — array of plugin names to preload with the module. Each module has its own plugins; see the module's documentation.
  • client_id — set only if 3D Digital Venue has provided one for you.
import { loadModule, setDVMVersion, setDefaultModuleVersion } from "@3ddv/dvm";

setDVMVersion("stable"); // stable is already set by default
setDefaultModuleVersion("map_viewer", "stable");

loadModule("map_viewer", { container: "container-id" })
    .then((viewer) => {
        return viewer.loadMap({ venue_id: "venue" });
    })
    .then(() => {
        console.log("map loaded");
    });

Feature detection and modern build

Starting with v2.8, @3ddv/dvm no longer performs any feature detection itself, so it will never try to eval or run inline code on your page. The DVM library it downloads from our CDN does perform feature detection by default, but that work is isolated in a separate file — if it's blocked by a browser extension or CSP, the rest of the loader still runs.

Feature detection can be turned off entirely. Call allowFeatureDetection(false) before any module instancing:

import { loadModule, allowFeatureDetection } from "@3ddv/dvm";

allowFeatureDetection(false);

loadModule("3d_viewer", { container: "container-id" });

It can also be disabled per call:

loadModule("3d_viewer", { container: "container-id", feature_detection: false });

When feature detection is disabled, the ES5 build is downloaded by default. You can force the ES2020+ build with useModernBuild(true) or the per-call modern: true flag:

import { loadModule, useModernBuild } from "@3ddv/dvm";

useModernBuild(true);

// or, per call:
loadModule("3d_viewer", { container: "container-id", modern: true });

Builtin versions

You can specify the specific version with which this package was published:

import { loadModule, setDVMVersion, setDefaultModuleVersion } from '@3ddv/dvm';

setDVMVersion('builtin');
setDefaultModuleVersion('map_viewer', 'builtin');
setDefaultModuleVersion('3d_viewer', 'builtin');

loadModule('map_viewer', { container: 'container-id' })
    .then((viewer) => {
      ...
    });

Specific versions

You can specify a specific numeric version of a module.

import { loadModule, setDVMVersion, setDefaultModuleVersion } from '@3ddv/dvm';

setDefaultModuleVersion('map_viewer', '2.5.6');

loadModule('map_viewer', { container: 'container-id' })
    .then((viewer) => {
      ...
    });

版本与发布记录

@3ddv/dvm 共发布 123 个版本,首次发布于 2023/10/26;过去 12 个月发布了 3 个版本。

版本发布日期距今
2.8.5latest2026/06/035 个月前
2.8.32026/05/145 个月前
2.7.82025/11/1911 个月前
2.7.72025/10/281 年前
2.7.62025/08/251.2 年前
2.7.42025/05/071.5 年前

关于 @3ddv/dvm 的常见问题

@3ddv/dvm 是什么?

This package is a helper to use DVM. Instead of just adding the script to your website, you can use this package to:

如何安装 @3ddv/dvm?

在项目目录运行 npm install @3ddv/dvm,或使用 pnpm add / yarn add / bun add。

@3ddv/dvm 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@3ddv/dvm 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@3ddv/dvm 可以商用吗?

@3ddv/dvm 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@3ddv/dvm 的下载量有多少?

根据 npm 官方下载统计,@3ddv/dvm 在 2026/10/05 – 2026/11/03 这 30 天内被下载 17,748 次,日均约 592 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@3ddv/dvm 还在维护吗?

最新版本 2.8.5 发布于 2026/06/03(5 个月前);至今共发布 123 个版本,其中过去 12 个月发布了 3 个;首次发布于 2023/10/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。