🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

dim-mlamp

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dim-mlamp

## 📦 如何安装

latest
npmnpm
Version
1.0.0-alpha.17
Version published
Maintainers
1
Created
Source

3D 可视化项目

📦 如何安装

npm isntall dim-mlamp

🔨 如何使用

  • 创建一个基础场景。包含相机(camera)、图层(layers)、渲染器(renderer)、场景(scene)
import { Dim } from 'dim-mlamp';
const dim = new Dim({
    axesHelper: true,
    container: document.getElementById('app'),
    position: 'center', // 可选
    scale: 'normal', // 可选
    dblClick: callback,
});
function callback(geo) {
    console.log(geo);
}
  • 创建一个几何体。
import { Obj3 } from 'dim-mlamp';
const fillD = [
    {
        position: [0, 0, 0],
        color: 0xff0000,
        materialType: 'MeshPhongMaterial', // 几何体材质
        geometryType: 'SphereBufferGeometry', // 几何体类型
    },
];
const cubes = new Obj3({ type: 'geo', userData: fillD });
dim.sence.add(cubes);

⌨️ 参数

Dim 参数

  • position —— 相机初始化的位置

    参数说明类型默认值
    center45° 看向中心string
    leftZ 轴看向圆心string
    rightX 轴看向圆心string
    topY 轴看向圆心string
    number[]可以自定义一个角度number[x,y,z]
  • scale —— 相机初始化视距,同时影响可缩放范围

    参数说明类型默认值
    normalscale 值为 1,表示最接近人眼的视距string
    nearscale 值为 3string
    farscale 值为 0.6string
    number可以自定义一个距离number 或'number
  • dblClick —— 双击物体回调函数

    参数说明类型默认值
    callback双击物体的回调函数,参数为点击到的物体对象(geo) => void

✨ 方法

相机方法

  • setPosition —— 设置相机位置 参数 1 详见 dim 类参数 —— position 参数 2
    参数说明类型默认值
    number[]可以自定义一个焦点,即相机指向的中心点number[x,y,z][0,0,0]
// 以x:10,y:10,z:10为中心。相机在中心点左上45°,即[55, 55, 55]
dim.camera.setPosition('center', [10, 10, 10]);
  • setScale —— 设置缩放 参数 1 详见 dim 类参数 —— scale
dim.camera.setScale('far');

Keywords

three

FAQs

Package last updated on 08 Dec 2021

Did you know?

Socket

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