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

@tlbs/galaxy-model

v0.1.21

Published

for 3d model render

Downloads

445

Readme

模型JSSDK接口文档

[toc]

创建实例

初始化实例。

构造函数

  • 语法

    new TModel.Scene(container, sceneOptions);
  • 参数说明

| 参数名 | 类型 | 说明 | | ------------ | --------------------- | ------------------------------------------------------------ | | container | String/HTMLDIVElement | 模型DOM容器,创建模型需要在页面中创建一个空div元素,传入该div元素或者该元素的id | | sceneOptions | Object | 模型查看器初始化参数,对象规范详见SceneOptions |

SceneOptions 对象规范

模型配置参数。

属性

| 名称 | 类型 | 说明 | | ------------- | -------------- | ------------------------------------------------------ | | light | object | 可选,默认为环境光,颜色fff, 强度为1 | | cameraPostion | TModel.Vector3 | 可选,默认为[0.100.0],透视相机,fov为60 , 由position 指向[0,0,0] |

方法

| 方法名 | 返回值 | 说明 | | ------------------------------------------------------------ | ------------- | -------------------------------------------------------- | | addModel(Model: Model) | model | 新增模型 | | deleteModel(modelId: String) | this | 删除模型 | | addLight(lightOptions: LightOptions) | | 增加光源 | | updateLight(lightId: String, lightOptions: LightOptions) | this | 更新光源 | | deleteLight(light: TModel.Light) | this | 删除光源 | | getLights() | THREE.Light[] | 获取所有光源 | | updateCamera(cameraOptions: CameraOptions) | this | 更新相机 | | setBackground(path: String) | this | path为图片路径,把一张图片作为模型渲染背景 | | clearBackground() | this | 清空背景 | | easeTo(easeToOptions: EaseToOptions) | this | target:需要过渡的物体 dest:终点位置 type:过渡动画类型 | | addLine(: TModel.Color, start:TModel.Vector3, end: TModel.Vector3 ) | this | color:线颜色 start:线起点位置 end:线终点位置 | | deleteLine(target: TModel.Object3D) | this | 删除线 | | addText(textOptions: textOptions) | this | 新增文字 | | deleteText(textOptions: textOptions) | this | 删除文字 | | addAnimation(animationOptions: AnimationOptions) | this | type:动画类型 position:动画位置 |

Model类

初始化实例。

构造函数

  • 语法

    new TModel.Model(modelOptions);
  • 参数说明

| 参数名 | 类型 | 说明 | | ------------ | ------ | ------------------------------------------ | | modelOptions | Object | 模型初始化参数,对象规范详见ModelOptions |

ModelOptions 对象规范

创建模型对象的配置参数。

属性

| 名称 | 类型 | 说明 | | :------: | :----------------: | :----------------------------------------------------------: | | url | String | 模型资源url | | position | TModel.Vector3 | 模型锚点所对应的坐标,格式为[x, y, z],默认为[0, 0, 0] | | id | String | (可选)模型唯一标识 | | rotation | TModel.Vector3 | (可选)模型XYZ三轴上的旋转角度,格式为[x, y, z],默认为[0, 0, 0] | | scale | Number | TModel.Vector3 | (可选)模型在XYZ三轴上的缩放比例。若为数字,则三轴均以该比值进行缩放;若为数组,则可分别指定三轴缩放比例,格式为[x, y, z]。默认为1 |

方法

| 方法名 | 返回值 | 说明 | | :------------------------------------------: | :------: | :-----------------------------------------------------: | | setPosition(position: TModel.Vector3) | this | 设置模型锚点所在的xyz坐标 | | getBoundary | TModel.Vector3 | [xy, xz, yz ] 表示三个坐标轴方向的长度 | | setRotation(rotation: TModel.Vector3) | this | 设置模型旋转角度 | | setScale(scale: Number | TModel.Vector3) | this | 设置模型缩放比例 | | getPosition() | TModel.Vector3 | 获取模型锚点所在的xyz坐标 | | getRotation() | TModel.Vector3 | 获取模型旋转角度 | | getScale() | TModel.Vector3 | 获取模型缩放比例 | | destroy() | this | 销毁模型对象 | | show() | this | 显示模型 | | hide() | this | 隐藏模型 | | on(eventName:String, listener:Function) | this | 添加listenereventName事件的监听器数组中 | | off(eventName:String, listener:Function) | this | 从eventName事件的监听器数组中移除指定的listener |

事件

|事件名 |返回值 |说明 | |:--| |loaded |ModelLoadEvent |模型资源加载完成 | |loading |ModelLoadEvent |模型资源加载中 | |load_failed |ModelLoadEvent |模型资源加载失败 |

ModelLoadEvent 对象规范

模型对象的加载事件返回对象。 属性

|名称 |类型 |说明 | |:--| |target |Model |事件的目标模型对象 | |error |Error |加载失败的错误对象,load_failed事件返回 |

LightOptions 对象规范

光源配置参数,不同类型的光源可配置参数不同,详见下表。

属性

| 名称 | 类型 | 说明 | | :-------: | :--------: | :----------------------------------------------------------: | | type | LIGHT_TYPE | 光源类型 | | id | String | (通用)光源id,默认为随机字符串 | | color | String | (通用)光色,支持rgb()#RRGGBB形式,默认为#FFFFFF | | intensity | Number | (通用)光强,默认为1.0 | | direction | TModel.Vector3 | (方向光)光线投射方向,为一个三维向量,格式为[x, y, z], 默认目标位置为[0,0,0] | | position | TModel.Vector3 | (点光源)光源的xyz位置 |

LIGHT_TYPE 常量说明

光源类型常量说明。

| 常量 | 说明 | | :------------------: | :----: | | LIGHT_TYPE.AMBIENT | 环境光 | | LIGHT_TYPE.DIRECTION | 方向光 | | LIGHT_TYPE.POINT | 点光源 |

cameraOptions

  • 参数说明

| 参数名 | 类型 | 说明 | | ---------- | -------------------------------------------------- | ------------------------------------------- | | position | TModel.Vector3 | 位置xyz | | type | String | 类型,正交Orthographic和透视Perspective两种 | | properties | PerspectiveCameraOptions/OrthographicCameraOptions | 相机参数 |

PerspectiveCameraOptions

| 数名 | 类型 | 说明 | | ------ | ------ | -------------------------------------------- | | fov | Number | (可选)摄像机视锥体垂直视野角度,默认为60 | | aspect | Number | (可选)摄像机视锥体长宽比,默认为容器长宽比 | | near | Number | (可选)摄像机视锥体近端面 | | far | Number | (可选)摄像机视锥体远端面 |

OrthographicCameraOptions

| 参数名 | 类型 | 说明 | | ------ | ------ | ------------------ | | left | Number | 摄像机视锥体左侧面 | | right | Number | 摄像机视锥体右侧面 | | top | Number | 摄像机视锥体上侧面 | | bottom | Number | 摄像机视锥体下侧面 | | near | Number | 摄像机视锥体近端面 | | far | Number | 摄像机视锥体远端面 |

textOptions类

  • 参数说明

| 参数名 | 类型 | 说明 | | -------- | -------- | ----------------- | | text | String | 文字内容 | | position | TModel.Vector3 | 坐标[x, y, z] | | rotation | TModel.Vector3 | 旋转[x, y, z] | | scale | TModel.Vector3 | 缩放比例[x, y, z] | | style | Object | 文字参数 |

style

| 参数名 | 类型 | 说明 | | ------ | ------------ | -------- | | font | String | 字体 | | size | Number | 字体大小 | | height | Number | 文本厚度 | | color | TModel.Color | 字体颜色 |

EaseToOptions 对象规范 过渡动画

| 参数名 | 类型 | 说明 | | -------- | --------------- | ---------------- | | target | TModel.Object3D | 目标动画物体 | | dest | TModel.Vector3 | 目标动画终点位置 | | easeType | EaseType | 过渡动画类型 |

EaseType 对象规范

过渡动画类型

| 类型 | 说明 | | ------------ | ------------------------------------------------------------ | | QuadraticIn | 符合二次函数的动画。会在初始较慢的速度,然后加速到中间,并以较快的速度到终点 | | QuadraticOut | 与QuadraticIn相反 |

*** AnimationOptions *** | 参数名 | 类型 | 说明 | | -------- | -------------- | ------------ | | type | AnimationType | 动画效果类型 | | position | TModel.Vector3 | 动画效果位置 |

*** AnimationType 对象规范 *** 动画效果类型

| 名称 | 类型 | 说明 | | ---- | ------ | -------------------------- | | type | String | 可选项:streamer。流光效果 |