babylonjs基于自定义网格生成围栏动画

效果:

javascript 复制代码
import { Vector3, Mesh, MeshBuilder, StandardMaterial, Texture, Animation, Color3 } from "@babylonjs/core";
import imgUrl from "./image/headerwangge2.png"
// 创建模型护栏特效
export default class CreateRail {
    constructor(scene,) {
        this.scene = scene;
    };
    create() {
        let _position = [{x:1,y:1,z:1},{x:2,y:2,z:2}]
        if (_position.length <= 0) {
            return;
        }
        var mat = new StandardMaterial("mat", this.scene);
        mat.diffuseTexture = new Texture(imgUrl, this.scene);
        mat.diffuseTexture.vScale = 5;
        mat.diffuseTexture.hasAlpha = true;
        mat.backFaceCulling = false;
        mat.emissiveColor = Color3.White()
        const path = []
        for (let index = 0; index < _position.length - 1; index += 1) {
            path.push(new Vector3(_position[index].x, _position[index].y, _position[index].z));
            path.push(new Vector3(_position[index + 1].x, _position[index + 1].y, _position[index + 1].z));
        }
        let polygon = MeshBuilder.CreatePolygon("polygon", { shape: path, holes: [path], depth: 10, sideOrientation: Mesh.DOUBLESIDE }, this.scene);
        polygon.position.y = 10
        polygon.material = mat;
        Animation.CreateAndStartAnimation("ani", mat, "diffuseTexture.vOffset", 30, 20,
            1, 0, 1, undefined, undefined, this.scene);

    };

}

贴图 headerwangge2

相关推荐
椒盐螺丝钉3 小时前
Vue Router应用:组件跳转
前端·javascript·vue.js
顾安r3 小时前
11.20 开源APP
服务器·前端·javascript·python·css3
敲敲了个代码4 小时前
CSS 像素≠物理像素:0.5px 效果的核心密码是什么?
前端·javascript·css·学习·面试
二川bro4 小时前
第57节:Three.js企业级应用架构
开发语言·javascript·架构
芳草萋萋鹦鹉洲哦5 小时前
【vue】调用同页面其他组件方法几种新思路
前端·javascript·vue.js
巴啦啦臭魔仙5 小时前
uniapp scroll-view自定义下拉刷新的坑
前端·javascript·uni-app
晨枫阳5 小时前
不同语言的元组对比
java·前端·javascript
柒儿吖6 小时前
Electron for 鸿蒙PC 窗口问题完整解决方案
javascript·electron·harmonyos
flashlight_hi7 小时前
LeetCode 分类刷题:404. 左叶子之和
javascript·算法·leetcode
木易 士心7 小时前
th-table 中 基于双字段计算的表格列展示方案
前端·javascript·angular.js