/* Js for , Version=1778124783 */
 if(typeof(v) != "object") v = {};v.pageID = 88;;
;
        // --- 关键修改：使用 {} 包裹代码 ---
        // 这样即使页面上有其他 3D 代码，变量也不会冲突，防止崩溃
        {
            const container = document.getElementById('bcl3-canvas-container');
            if (container) {
                // 场景
                const scene = new THREE.Scene();
                scene.background = new THREE.Color(0xf8f8f8); 
                // 相机
                const camera = new THREE.PerspectiveCamera(45, container.clientWidth / container.clientHeight, 0.1, 1000);
                camera.position.set(0, 1, 8); 
                // 渲染器
                const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
                renderer.setSize(container.clientWidth, container.clientHeight);
                renderer.setPixelRatio(window.devicePixelRatio);
                container.appendChild(renderer.domElement);
                // CSS 2D 渲染器
                const labelRenderer = new THREE.CSS2DRenderer();
                labelRenderer.setSize(container.clientWidth, container.clientHeight);
                labelRenderer.domElement.className = 'css-label-renderer';
                container.appendChild(labelRenderer.domElement);
                // 灯光
                const ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
                scene.add(ambientLight);
                const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
                directionalLight.position.set(5, 10, 7);
                scene.add(directionalLight);
                const backLight = new THREE.DirectionalLight(0xffffff, 0.3);
                backLight.position.set(-5, -5, -5);
                scene.add(backLight);
                // 材质
                const bMaterial = new THREE.MeshStandardMaterial({ 
                    color: 0xffb5b5, 
                    roughness: 0.9,
                    metalness: 0.1
                });
                const clMaterial = new THREE.MeshStandardMaterial({ 
                    color: 0x2eff2e, 
                    roughness: 0.9, 
                    metalness: 0.1 
                });
                const bondMaterial = new THREE.MeshStandardMaterial({ 
                    color: 0xeeeeee,
                    roughness: 0.5,
                    metalness: 0.2
                });
                // 分子组
                const moleculeGroup = new THREE.Group();
                scene.add(moleculeGroup);
                const bondLength = 2.4; 
                const clRadius = 0.8;
                const bRadius = 0.7;
                const bondRadius = 0.15;
                // 1. 硼原子 (B)
                const bGeometry = new THREE.SphereGeometry(bRadius, 32, 32);
                const bAtom = new THREE.Mesh(bGeometry, bMaterial);
                moleculeGroup.add(bAtom);
                const bDiv = document.createElement('div');
                bDiv.className = 'atom-label b-label';
                bDiv.textContent = 'B';
                const bLabel = new THREE.CSS2DObject(bDiv);
                bAtom.add(bLabel); 
                // 2. 氯原子 (Cl) - 平面三角形
                const positions = [];
                for (let i = 0; i < 3; i++) { const angle = (i * 120) * (Math.PI / 180); positions.push(new THREE.Vector3( bondLength * Math.cos(angle), bondLength * Math.sin(angle), 0 )); } positions.forEach(pos => {
                    const clGeometry = new THREE.SphereGeometry(clRadius, 32, 32);
                    const clAtom = new THREE.Mesh(clGeometry, clMaterial);
                    clAtom.position.copy(pos);
                    moleculeGroup.add(clAtom);
                    const clDiv = document.createElement('div');
                    clDiv.className = 'atom-label cl-label';
                    clDiv.textContent = 'Cl';
                    const clLabel = new THREE.CSS2DObject(clDiv);
                    clAtom.add(clLabel);
                    const direction = new THREE.Vector3().copy(pos).normalize();
                    const distance = pos.length();
                    const cylinderGeometry = new THREE.CylinderGeometry(bondRadius, bondRadius, distance, 16);
                    const bond = new THREE.Mesh(cylinderGeometry, bondMaterial);
                    const axis = new THREE.Vector3(0, 1, 0); 
                    const quaternion = new THREE.Quaternion();
                    quaternion.setFromUnitVectors(axis, direction);
                    bond.setRotationFromQuaternion(quaternion);
                    bond.position.copy(pos).multiplyScalar(0.5);
                    moleculeGroup.add(bond);
                });
                // 控制
                if (typeof THREE.OrbitControls !== 'undefined') {
                    const controls = new THREE.OrbitControls(camera, renderer.domElement); // 注意绑定到 renderer 而不是 labelRenderer 可能会更灵敏
                    controls.enableDamping = true;
                    controls.dampingFactor = 0.05;
                    controls.enableZoom = true; 
                    controls.autoRotate = true;
                    controls.autoRotateSpeed = 1.5;
                    function animate() {
                        requestAnimationFrame(animate);
                        controls.update();
                        renderer.render(scene, camera);
                        labelRenderer.render(scene, camera);
                    }
                    animate();
                } else {
                    // 如果 Controls 没加载出来，至少渲染一帧静态的
                    renderer.render(scene, camera);
                    labelRenderer.render(scene, camera);
                    console.log("OrbitControls load failed, static render only.");
                }
                // 自适应
                window.addEventListener('resize', () => {
                    if (container) {
                        const width = container.clientWidth;
                        const height = container.clientHeight;
                        renderer.setSize(width, height);
                        labelRenderer.setSize(width, height);
                        camera.aspect = width / height;
                        camera.updateProjectionMatrix();
                    }
                });
            } else {
                console.error("找不到 ID 为 bcl3-canvas-container 的容器");
            }
        }
    