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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@soonspacejs/soonmanager-sync

v0.3.11

Published

soonmanager scene data sync for soonspacejs

Downloads

5

Readme

soonmanager-sync

空间平台生产的场景加载及数据读取插件。

样例

安装

npm install @soonspacejs/soonmanager-sync -S
# or
yarn add @soonspacejs/soonmanager-sync -S

使用方法

import SoonSpace from 'soonspacejs';
import SoonmanagerSyncPlugin from '@soonspacejs/soonmanager-sync';

const ssp = new SoonSpace({
  el: '#view',
  option: {},
  events: {},
});

const soonmanagerSync = ssp.install(
  SoonmanagerSyncPlugin,
  'soonmanagerSync'
);
consolo.log(soonmanagerSync);

方法

setBaseUrl

设置基础路径

定义

function setBaseUrl(url: string): void;

用法

soonmanagerSync.setBaseUrl('http://xxx.com/back-resource/');

必须要先调用 setBaseUrl, 才能加载效果、模型资源...

由于内部将 url 与 资源路径进行拼接获取资源, 所以参数的结尾需要加上斜线防止链接出错.

setGlobalSetting

同步背景、环境光、平行光、雾化效果

定义

interface SMYFogOptions extends FogOptions {
  visible: boolean;
}

interface GlobalSetting {
  color: IColor;
  ambientLight: AmbientLightOptions;
  hemisphereLight: HemisphereLightOptions;
  directionalLight: DirectionalLightOptions;
  fog: SMYFogOptions;
}

function setGlobalSetting(setting?: GlobalSetting): void;

用法

soonmanagerSync.setGlobalSetting({
  color: '#f65',
  ambientLight: {
    id: 'sm_ambientLight',
    color: '#9a9a9a',
    intensity: 1,
  },
  hemisphereLight: {
    id: 'hemisphereLight',
    skyColor: '#ffffff',
    groundColor: '#dddddd',
    intensity: 1,
    position: {
      x: 0,
      y: 0,
      z: 0,
    },
  },
  directionalLight: {
    id: 'sm_directionalLight',
    color: '#ffffff',
    intensity: 1,
    position: {
      x: 0,
      y: 500,
      z: 0,
    },
    target: {
      x: 0,
      y: -100,
      z: 0,
    },
  },
  fog: {
    color: 0xcce0ff,
    near: 500,
    far: 50000,
    visible: true,
  },
});

如果未传入 setting, 则获取 SoonManager 平台上保存的设置

参数

setting
  • 描述: 全局效果的对象集合
  • 必填:
  • 类型: GlobalSetting
GlobalSetting

loadScene

加载场景模型

定义

export interface LoadSceneOptions {
  targetId?: number | number[];
  targetLevel?: number;
  isIdleRest?: boolean;
  loadSceneAllSuccess?: () => void;
}

function loadScene(options?: LoadSceneOptions): Promise<void>;

用法

/**
 * 指定开始加载的树节点 ID
 * 未指定或指定为空,从根节点开始加载场景
 * 指定的 ID 无法命中节点,不会加载任何模型
 * targetId: xxxxx | [xxxxx],
 */

/**
 * 从指定节点开始,向下加载的的层级深度。
 * 等于 1 时只加载根节点
 * 不设置时加载全部层级子集
 * targetLevel: 2,
 */

/**
 * 是否利用页面交互空闲时间去加载剩余模型,当 targetLevel 大于1或未指定时生效
 * 可以提升初始化时,用户的交互等待时间
 * isIdleRest: true
 */

/**
 * 当前 loadScene 加载模型全部完成的回调
 * loadSceneAllSuccess: () => {}
 */
soonmanagerSync
  .loadScene({
    isIdleRest: true,
    loadSceneAllSuccess: () => {
      console.log('全部模型加载完成');
    },
  })
  .then(() => {
    console.log('主层级加载完成');
  });

参数

options
  • 描述: 场景加载选项
  • 必填:
  • 类型: LoadSceneOptions