npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@soonspacejs/plugin-cps-soonmanager

v2.15.18

Published

Sync cps soonmanager data plugin for SoonSpace.js

Readme

@soonspacejs/plugin-cps-soonmanager

Sync cps soonmanager data plugin for SoonSpace.js

Web Worker 场景加载

loadSceneAndSemanticInWorker 会与场景资源加载并行获取并解析语义数据。墙、柱和窗对象在主线程离场创建,全部完成后统一挂载、注册缓存并刷新场景。

该方法会将场景树中的空间、楼层、房间、门、窗、楼梯、电梯等语义辅助面,以及 semantic_model 中除虚拟墙外的墙、柱、窗语义面设置为完全透明并关闭深度写入;VirtualWall 为真的墙仍按墙体样式显示。透明模式只通过插件内部参数启用,loadSceneloadSceneAndSemantic 继续使用原有语义颜色及透明度。

const scenePromise = cpsSoonmanagerPlugin.loadSceneAndSemanticInWorker(
  { path, key, applyPresetEffects: false },
  undefined,
  {
    onStage: event => console.info('[SceneLoad]', event),
    freezeSceneWorldMatrix: true,
  }
)

// 业务接口不阻塞场景加载;接口先返回、加载中返回或加载后返回均可应用。
fetchFullInstanceTree()
  .then( createWorkIdMap )
  .then( workIdMap => cpsSoonmanagerPlugin.applyWorkIdMap( workIdMap ) )

const result = await scenePromise

onStage 仍会通知各加载阶段和状态,但不再采集或返回阶段耗时;loadSceneAndSemanticInWorker 的结果也不再包含 timings 字段。

第二个参数与 loadSceneloadSceneAndSemantic 相同,仍支持加载前传入 RecordMap 类型的 workIdMap。业务 ID 也可以通过 applyWorkIdMap 在加载过程中或加载完成后传入。未创建对象的映射会保留为 pending,并在对象创建或语义对象统一提交后自动应用;已创建对象会立即更新 userData.work_idextraIds 和 SoonSpace 对象缓存。

加载后传入的映射不会追溯执行 hiddenObjects 判断;如果需要使用业务 ID 控制初始隐藏状态,应继续通过 loadSceneAndSemanticInWorker 第二个参数提前传入。

示例文件:example/semantic-worker-scene.html。示例默认使用场景 ID 465391669186895872,鉴权 token 通过运行时 URL 参数 token 传入,不写入源码或构建产物。

示例会调用 UStudio 的 /boss/twins/scene/v1/instance-tree 接口获取全量实例树,不传 include_twins_identifiers。遍历实例树后使用 out_instance_id 作为场景对象 ID,使用 twins_instance_id 作为业务 ID,生成以下结构并传给插件:

workIdMap[out_instance_id] = { work_id: twins_instance_id }

实例树请求不会计入场景加载等待时间。实例树加载耗时、映射数量和 applyWorkIdMap 结果会独立输出到控制台;最终映射保存在 window.sceneWorkerWorkIdMap,异步任务保存在 window.sceneWorkerWorkIdPromise 供示例调试。

示例支持在场景资源加载过程中传入单个组件 ID:componentId 对应 out_instance_idcomponentWorkId 对应 twins_instance_id。如果不传 componentWorkId,示例会从全量实例树中查找:

?componentId=<out_instance_id>&componentWorkId=<twins_instance_id>

场景加载 Promise 启动后会立即尝试调用 applyWorkIdMap,并由模型进度事件再次兜底;调用结果会输出到控制台。若对象尚未创建,映射会先进入 pending,插件会在对象创建后自动补齐。

Worker 相关源码按职责拆分:

  • semantic-worker.config.ts:墙、柱、窗的解析配置。
  • semantic-worker.parser.ts:纯数据解析和批次分组,不依赖 SoonSpace 实例。
  • semantic.worker.ts:Worker 入口,负责资源获取和调用解析器。
  • semantic-worker.client.ts:主线程 Worker 生命周期、取消和消息协议。
  • semantic-worker.shared.ts:取消、错误和计时结果的共享辅助函数。
  • semantic-batch.utils.ts:主线程离场创建、统一挂载和失败清理。
  • semantic.utils.ts:旧版逐对象语义加载逻辑,供兼容 API 使用。