zoukankan      html  css  js  c++  java
  • IfcContext

    IfcContext

    学习

    class IfcContext {
        constructor(options) {
            this.render = () => {
                requestAnimationFrame(this.render);
                this.updateAllComponents();
            };
            if (!options.container)
                throw new Error('Could not get container element!');
            this.options = options;
            this.events = new IfcEvents();
            this.items = this.newItems();
            this.scene = new IfcScene(this);
            this.renderer = new IfcRenderer(this);
            this.ifcCamera = new IfcCamera(this);
            this.events.publish(IfcEvent.onCameraReady);
            this.clippingPlanes = [];
            this.ifcCaster = new IfcRaycaster(this);
            this.clock = new Clock(true);
            this.ifcAnimator = new Animator();
            this.setupWindowRescale();
            this.render();
        }
        getScene() {
            return this.scene.scene;
        }
        getRenderer() {
            return this.renderer.basicRenderer;
        }
        getRenderer2D() {
            return this.renderer.renderer2D;
        }
        getCamera() {
            return this.ifcCamera.activeCamera;
        }
        getIfcCamera() {
            return this.ifcCamera;
        }
        getDomElement() {
            return this.getRenderer().domElement;
        }
        getDomElement2D() {
            return this.getRenderer2D().domElement;
        }
        getContainerElement() {
            return this.options.container;
        }
        getDimensions() {
            const element = this.getContainerElement();
            return new Vector2(element.clientWidth, element.clientHeight);
        }
        getClippingPlanes() {
            return this.clippingPlanes;
        }
        getAnimator() {
            return this.ifcAnimator;
        }
        getCenter(mesh) {
            var _a;
            const center = new Vector3();
            mesh.geometry.computeBoundingBox();
            (_a = mesh.geometry.boundingBox) === null || _a === void 0 ? void 0 : _a.getCenter(center);
            return center;
        }
        addComponent(component) {
            this.items.components.push(component);
        }
        addClippingPlane(plane) {
            this.clippingPlanes.push(plane);
        }
        removeClippingPlane(plane) {
            const index = this.clippingPlanes.indexOf(plane);
            this.clippingPlanes.splice(index, 1);
        }
        castRay(items) {
            return this.ifcCaster.castRay(items);
        }
        castRayIfc() {
            return this.ifcCaster.castRayIfc();
        }
        fitToFrame() {
            this.ifcCamera.navMode[NavigationModes.Orbit].fitModelToFrame();
        }
        toggleCameraControls(active) {
            this.ifcCamera.toggleCameraControls(active);
        }
        updateAspect() {
            this.ifcCamera.updateAspect();
            this.renderer.adjustRendererSize();
        }
        updateAllComponents() {
            const delta = this.clock.getDelta();
            this.items.components.forEach((component) => component.update(delta));
        }
        setupWindowRescale() {
            window.addEventListener('resize', () => {
                this.updateAspect();
            });
        }
        newItems() {
            return {
                components: [],
                ifcModels: [],
                pickableIfcModels: []
            };
        }
    }

    ##############33

  • 相关阅读:
    自动发送邮件功能
    工作中常用的Android系统ADB命令收集
    商城系统必须知道的【订单、优惠金额、退货、实际营收】解释
    商城系统项目必须知道的专业数据指标
    接口加密思路
    Selenium使用Chrome模拟手机浏览器方法解析
    PHP上传图片基本代码示例
    iframe子页面获取父页面的点击事件
    javascript实现网页倒计时效果
    Crontab常用命令总结
  • 原文地址:https://www.cnblogs.com/herd/p/15563774.html
Copyright © 2011-2022 走看看