Socket
Socket
Sign inDemoInstall

i3v-3d-display

Package Overview
Dependencies
4
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    i3v-3d-display

轻量化3维展示器


Version published
Maintainers
1
Created

Readme

Source

🔨 示例

<template>
  <div class="home" ref="home"></div>
</template>

<script>
import Viewer, {
  THREE,
  Setting,
  Model,
  Transform,
  EControlType,
  ESourceType,
} from "i3v-3d-display";

export default {
  mounted() {
    const settings = new Setting({
      camInitDirection: [-1, 1, 1],
      sceneBgColor: 0xffffff,
    });

    const viewer = new Viewer(this.$refs["home"], settings);

    const models = [
      new Model({
        id: "1",
        sourceType: ESourceType.url,
        url: `http://220.168.85.72:10000/_temp/models2/house.glb`,
        transforms: [
          new Transform({
            position: [0, 0, 0],
            rotation: [0, 0, 0],
            scale: [1, 1, 1],
          }),
        ],
      }),
    ];

    viewer.load(models, Viewer.MODEL_FORMAT.GLB);
  },
};
</script>

<style lang="scss" scoped>
.home {
  width: 100%;
  height: 100%;
}
</style>

🔠 属性

Viewer

属性名类型默认值描述
rendererTHREE.WebGLRenderer-渲染器
sceneTHREE.Scene-场景
cameraTHREE.PerspectiveCamera-摄像头
directionalLightTHREE.DirectionalLight-平行光源
ambientLightTHREE.AmbientLight-环境光源
controlsOrbitControls-轨道控制器

Setting 设置类

属性名类型默认值描述
hasBtnRecoverViewingAnglebooleantrue工具栏-恢复原始视角的按钮是否显示
camInitDirection[number, number, number][1, 1, 1]初始的摄像头方位(三维向量)
axesHelperSizenumber0在场景原点的3色坐标的尺寸(为0时不会生成3色坐标)
isRotationAboveSkylinebooleanfalse锁定视角(不低于地平线)
sceneBgColornumber0x000000场景背景色
sceneBgGradientstring''场景背景色的渐变效果
isOutlineDrawnbooleanfalse是否描边
skyBoxHdrstring-天空盒 Hdr 文件,不设置则默认无天空盒
controlTypeEControlTypeCameraControls场景控制器类型
changeCenterWhenPanningbooleanfalse当平移场景时,是否改变旋转中心(仅当控制器类型为CameraControls时有效)

场景背景色的渐变效果详见 https://developer.mozilla.org/zh-CN/docs/Web/CSS/CSS_Images/Using_CSS_gradients

Model 模型类

属性名类型默认值描述
idstring-模型id(如果id一样,会被视为同一模型,已加载过的模型数据,不会再加载)
sourceTypeESourceTypeurl模型数据来源类型(Url地址还是ArrayBuffer)
urlstring-模型三维数据获取地址
arrayBufferPromise|ArrayBuffer-需要解析的glTF文件,值为一个ArrayBuffer
transformsArray[new Transform({})]模型的移动/旋转/缩放;如果数组长度大于1,则表示模型需要复制

Transform 移动、旋转、缩放类

属性名类型默认值描述
positionArray[0, 0, 0]位置
rotationArray[0, 0, 0]旋转
rotationOrderstring'XYZ'旋转顺序的字符串,默认为'XYZ'(必须是大写)
scaleArray[1, 1, 1]缩放

Keywords

FAQs

Last updated on 25 May 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc