diff --git a/.claude/settings.local.json b/.claude/settings.local.json deleted file mode 100644 index fef15a3..0000000 --- a/.claude/settings.local.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "permissions": { - "allow": [ - "Bash(cd /d/VscodeProject/zhengte.babylonjs-sdk && npm run build 2>&1 | head -50)", - "Bash(find \"D:\\\\VscodeProject\\\\zhengte.babylonjs-sdk\\\\src\" -name \"*.ts\" -type f -exec grep -l \"class Dictionary\" {} \\\\;)", - "Bash(find \"D:\\\\VscodeProject\\\\zhengte.babylonjs-sdk\\\\src\" -name \"*.ts\" -type f -exec grep -l \"class.*Kernel\\\\|export.*kernel\" {} \\\\;)", - "Bash(npm run *)", - "Bash(mysql -u root -p123456 zt)", - "Bash(mysql *)" - ] - } -} diff --git a/.gitignore b/.gitignore index 11f19d9..b705d06 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,14 @@ -/node_modules/ -/public/ -/dist/ -/assets/ -nul \ No newline at end of file +# 大文件忽略 +*.zip +*.rar +*.7z +*.glb +*.gltf +*.png +*.jpg +*.jpeg +node_modules/ +dist/ +build/ +.DS_Store +*.log diff --git a/API_USAGE_EXAMPLE.md b/API_USAGE_EXAMPLE.md deleted file mode 100644 index 4796721..0000000 --- a/API_USAGE_EXAMPLE.md +++ /dev/null @@ -1,216 +0,0 @@ -# 模型管理 API 使用示例 - -## API 说明 - -### 1. 添加模型 - -```javascript -// 添加带有 rotation 控制类型的模型 -kernel.model.add({ - modelId: "卷帘大", - modelUrl: "https://sdk.zguiy.com/resurces/model/卷帘大.glb", - modelControlType: "rotation" -}); - -// 添加带有 color 控制类型的模型 -kernel.model.add({ - modelId: "小桌", - modelUrl: "https://sdk.zguiy.com/resurces/model/小桌.glb", - modelControlType: "color" -}); - -// 添加不带控制类型的模型 -kernel.model.add({ - modelId: "框架", - modelUrl: "https://sdk.zguiy.com/resurces/model/框架.glb" -}); -``` - -### 2. 替换模型 - -```javascript -// 替换模型并指定控制类型 -kernel.model.replace({ - modelId: "卷帘大", - modelUrl: "https://sdk.zguiy.com/resurces/model/新卷帘.glb", - modelControlType: "rotation" -}); -``` - -### 3. 模型变换 (Transform) - -```javascript -// 设置模型旋转 - 直接使用角度(默认) -kernel.transform.rotation({ - modelId: "卷帘大", - vector3: { x: 0, y: 90, z: 0 } // 绕Y轴旋转90度 -}); - -// 更多角度示例 -kernel.transform.rotation({ - modelId: "卷帘大", - vector3: { x: 0, y: 180, z: 0 } // 旋转180度 -}); - -kernel.transform.rotation({ - modelId: "卷帘大", - vector3: { x: 45, y: 90, z: 0 } // X轴45度,Y轴90度 -}); - -// 如果需要使用弧度,设置 useDegrees: false -kernel.transform.rotation({ - modelId: "卷帘大", - vector3: { x: 0, y: Math.PI / 2, z: 0 }, - useDegrees: false -}); - -// 设置模型位置 -kernel.transform.position({ - modelId: "小桌", - vector3: { x: 10, y: 0, z: 5 } -}); - -// 设置模型缩放 -kernel.transform.scale({ - modelId: "框架", - vector3: { x: 1.5, y: 1.5, z: 1.5 } // 放大1.5倍 -}); -``` - -### 4. 点击事件回调 - -```javascript -kernel.on('model:click', (data) => { - console.log('点击的网格名称:', data.meshName); - console.log('点击的网格对象:', data.pickedMesh); - console.log('点击的3D坐标:', data.pickedPoint); - console.log('材质名称:', data.materialName); - console.log('模型控制类型:', data.modelControlType); // 'rotation' | 'color' | undefined - - // 根据控制类型执行不同操作 - if (data.modelControlType === 'rotation') { - console.log('这是一个可旋转的模型'); - // 执行旋转相关操作 - 直接使用角度 - kernel.transform.rotation({ - modelId: "卷帘大", - vector3: { x: 0, y: 180, z: 0 } - }); - } else if (data.modelControlType === 'color') { - console.log('这是一个可改变颜色的模型'); - // 执行颜色相关操作 - kernel.material.color(data.materialName, '#FF0000'); - } -}); -``` - -## ModelControlType 说明 - -- `rotation`: 表示该模型支持旋转控制 -- `color`: 表示该模型支持颜色控制 -- `undefined`: 未指定控制类型 - -## 完整示例 - -```javascript -import { kernel } from './index.js'; - -const config = { - container: document.querySelector('#renderDom'), - modelUrlList: [], - env: { - envPath: 'https://sdk.zguiy.com/resurces/hdr/hdr.env', - intensity: 1.2, - rotationY: 0.3, - background: true - }, -}; - -kernel.init(config); - -// 添加多个模型 -kernel.model.add({ - modelId: "框架", - modelUrl: "https://sdk.zguiy.com/resurces/model/框架.glb" -}); - -kernel.model.add({ - modelId: "卷帘大", - modelUrl: "https://sdk.zguiy.com/resurces/model/卷帘大.glb", - modelControlType: "rotation" -}); - -kernel.model.add({ - modelId: "小桌", - modelUrl: "https://sdk.zguiy.com/resurces/model/小桌.glb", - modelControlType: "color" -}); - -// 模型加载完成后设置变换 -kernel.on('model:loaded', () => { - // 设置初始位置 - kernel.transform.position({ - modelId: "小桌", - vector3: { x: 5, y: 0, z: 0 } - }); - - // 设置初始旋转 - 直接使用角度 - kernel.transform.rotation({ - modelId: "卷帘大", - vector3: { x: 0, y: 45, z: 0 } - }); - - // 设置缩放 - kernel.transform.scale({ - modelId: "框架", - vector3: { x: 1.2, y: 1.2, z: 1.2 } - }); -}); - -// 监听点击事件 -kernel.on('model:click', (data) => { - console.log('模型点击数据:', data); - - if (data.modelControlType === 'rotation') { - // 处理旋转逻辑 - 每次点击旋转45度 - kernel.transform.rotation({ - modelId: data.meshName, - vector3: { x: 0, y: 45, z: 0 } - }); - } else if (data.modelControlType === 'color') { - // 处理颜色变更逻辑 - kernel.material.color(data.materialName, '#FF0000'); - } -}); -``` - -## Transform API 详细说明 - -### rotation - 旋转 -- 参数:`{ modelId: string, vector3: { x, y, z }, useDegrees?: boolean }` -- **默认使用角度**:直接传递 90、180 等角度值 -- 如需使用弧度,设置 `useDegrees: false` -- 示例: - ```javascript - // 使用角度(默认,推荐) - kernel.transform.rotation({ - modelId: "model1", - vector3: { x: 0, y: 90, z: 0 } - }); - - // 使用弧度 - kernel.transform.rotation({ - modelId: "model1", - vector3: { x: 0, y: Math.PI / 2, z: 0 }, - useDegrees: false - }); - ``` - -### position - 位置 -- 参数:`{ modelId: string, vector3: { x, y, z } }` -- 单位:场景单位 -- 坐标系:右手坐标系(X右,Y上,Z前) - -### scale - 缩放 -- 参数:`{ modelId: string, vector3: { x, y, z } }` -- 单位:倍数(1.0 = 原始大小) -- 可以设置不同轴向的缩放比例 diff --git a/ScreenShot_2026-05-16_193237_299.png b/ScreenShot_2026-05-16_193237_299.png deleted file mode 100644 index d36d5ed..0000000 Binary files a/ScreenShot_2026-05-16_193237_299.png and /dev/null differ diff --git a/ScreenShot_2026-05-16_194139_487.png b/ScreenShot_2026-05-16_194139_487.png deleted file mode 100644 index a31a0c7..0000000 Binary files a/ScreenShot_2026-05-16_194139_487.png and /dev/null differ diff --git a/ScreenShot_2026-05-17_130307_268.png b/ScreenShot_2026-05-17_130307_268.png deleted file mode 100644 index 0a576d7..0000000 Binary files a/ScreenShot_2026-05-17_130307_268.png and /dev/null differ diff --git a/ScreenShot_2026-05-17_142225_495.png b/ScreenShot_2026-05-17_142225_495.png deleted file mode 100644 index e62ece6..0000000 Binary files a/ScreenShot_2026-05-17_142225_495.png and /dev/null differ diff --git a/ScreenShot_2026-05-17_165150_324.png b/ScreenShot_2026-05-17_165150_324.png deleted file mode 100644 index 8247623..0000000 Binary files a/ScreenShot_2026-05-17_165150_324.png and /dev/null differ diff --git a/ScreenShot_2026-05-18_175704_601.png b/ScreenShot_2026-05-18_175704_601.png deleted file mode 100644 index 0ab9646..0000000 Binary files a/ScreenShot_2026-05-18_175704_601.png and /dev/null differ diff --git a/ScreenShot_2026-05-20_195151_973.png b/ScreenShot_2026-05-20_195151_973.png deleted file mode 100644 index 1a9da24..0000000 Binary files a/ScreenShot_2026-05-20_195151_973.png and /dev/null differ diff --git a/ScreenShot_2026-05-21_094326_711.png b/ScreenShot_2026-05-21_094326_711.png deleted file mode 100644 index 54d68cc..0000000 Binary files a/ScreenShot_2026-05-21_094326_711.png and /dev/null differ diff --git a/ScreenShot_2026-05-21_102602_338.png b/ScreenShot_2026-05-21_102602_338.png deleted file mode 100644 index 8014c85..0000000 Binary files a/ScreenShot_2026-05-21_102602_338.png and /dev/null differ diff --git a/assets/卷帘大.glb b/assets/卷帘大.glb deleted file mode 100644 index 9710eb9..0000000 Binary files a/assets/卷帘大.glb and /dev/null differ diff --git a/assets/卷帘小.glb b/assets/卷帘小.glb deleted file mode 100644 index 12a2012..0000000 Binary files a/assets/卷帘小.glb and /dev/null differ diff --git a/assets/拆分.rar b/assets/拆分.rar deleted file mode 100644 index 1e752bf..0000000 Binary files a/assets/拆分.rar and /dev/null differ diff --git a/assets/框架.glb b/assets/框架.glb deleted file mode 100644 index 7aed96e..0000000 Binary files a/assets/框架.glb and /dev/null differ diff --git a/assets/百叶A.glb b/assets/百叶A.glb deleted file mode 100644 index da9daf3..0000000 Binary files a/assets/百叶A.glb and /dev/null differ diff --git a/assets/百叶B.glb b/assets/百叶B.glb deleted file mode 100644 index dc62dd4..0000000 Binary files a/assets/百叶B.glb and /dev/null differ diff --git a/assets/百叶C.glb b/assets/百叶C.glb deleted file mode 100644 index 9d58ad8..0000000 Binary files a/assets/百叶C.glb and /dev/null differ diff --git a/assets/百叶D.glb b/assets/百叶D.glb deleted file mode 100644 index 1a9b6b4..0000000 Binary files a/assets/百叶D.glb and /dev/null differ diff --git a/assets/百叶窗小.glb b/assets/百叶窗小.glb deleted file mode 100644 index 8efe915..0000000 Binary files a/assets/百叶窗小.glb and /dev/null differ diff --git a/examples/app-global.js b/examples/app-global.js index 71232b6..331aedc 100644 --- a/examples/app-global.js +++ b/examples/app-global.js @@ -35,7 +35,7 @@ const init = async (customConfig = {}) => { const defaultConfig = { container: document.querySelector('#renderDom'), modelUrlList: [], - env: { envPath: 'https://cdn.files.zguiy.com/zt/environment.env', intensity: 1.2, rotationY: 0.3, background: false }, + env: { envPath: 'https://cdn.files.zguiy.com/zt/environment.env', intensity: 1.5, rotationY: 0.3, background: false }, gizmo: { position: false, rotation: false, @@ -53,6 +53,7 @@ const init = async (customConfig = {}) => { // 合并用户自定义配置 const config = { ...defaultConfig, ...customConfig }; kernel.init(config); + await getAutoLoadModelList() } //初始化加载模型 @@ -97,10 +98,12 @@ const getPlacementZone = async (sku) => { let division_include = [] // 同时包含10和13 const only10_13 = /(?=.*10)(?=.*13)/.test(pergolaSku) - // 只包含10 无13 无12 - const only10 = /(?=.*10)(?!.*13)(?!.*12)/.test(pergolaSku) + // 只包含10 无13 无12 无20 + const only10 = /(?=.*10)(?!.*13)(?!.*12)(?!.*20)/.test(pergolaSku) // 同时包含10和12 const only10_12 = /(?=.*10)(?=.*12)/.test(pergolaSku) + // 同时包含10和20 + const only10_20 = /(?=.*10)(?=.*20)/.test(pergolaSku) // 1. 只要字符串里包含 10,就返回 true const has10 = /10/.test(sku); @@ -131,6 +134,25 @@ const getPlacementZone = async (sku) => { if (only10_12 && has10) { division_include.push('左', '右') } + //棚子同时包10和20的并且含配件是10 + if (only10_20 && has10) { + + if (pergolaSku === "SPF111S1020PILLAR4PCS") { + division_include.push('左', '右') + } + else { + division_include.push('前', '后', '左', '右', "前1", "后1", "前2", "后2") + } + } + + //棚子同时包10和20的并且含配件是13 + if (only10_20 && has13) { + + if (pergolaSku === "SPF111S1020PILLAR4PCS") { + division_include.push('前', '后') + } + } + const response = await fetch(getApiUrl(`/api/product-configs/by-sku/${sku}`)); const result = await response.json(); @@ -181,48 +203,48 @@ const getEvent = async (dropzone_data, sku) => { //点击放置区域执行事件 一般是换配件 const executeEvent = async (dropzone_data, result, sku) => { - const kernel = getKernel(); - - const { wallName, index, transform } = dropzone_data; - const { position, rotation } = transform; - - let modelId = null; // 在外部声明,用于在两个循环之间传递 - let modelName = null; - let pergolaSku = null; // 用于存储棚子的 SKU - - // 第一次循环:处理 change_model - for (const event of result.data.events) { - if (event.event_type === 'change_model') { - const { name, file_url, model_control_type, category } = event.target_data; + const kernel = getKernel(); - // 生成唯一的模型ID - modelId = Date.now(); - modelName = name; - kernel.dropZone.recordModelPlacement(wallName, index, name + '_' + modelId); - - await kernel.model.add({ - modelName: name, - modelId: modelId, - modelUrl: file_url, - modelControlType: model_control_type, - drag: { - enable: true, - axis: rotation.y === 0 || rotation.y === 180 ? 'x' : 'z', - step: 0.1, - snapToZone: true, // 拖拽吸附到最近的分割区域 - returnWhenOutOfBounds: true, // 拖拽到区域外时返回原位置 - handleOccupiedZone: true, // 处理已占用区域(false=允许重叠) - occupiedZoneAction: 'replace' // 当开关3=true时的行为:'return'=返回原位置,'replace'=替换 - }, - transform: { - position: position, - rotation: rotation, - } - }); - - console.log(`百叶模型已放置为 ${name + '_' + modelId}`); - } - } + const { wallName, index, transform } = dropzone_data; + const { position, rotation } = transform; + + let modelId = null; // 在外部声明,用于在两个循环之间传递 + let modelName = null; + let pergolaSku = null; // 用于存储棚子的 SKU + + // 第一次循环:处理 change_model + for (const event of result.data.events) { + if (event.event_type === 'change_model') { + const { name, file_url, model_control_type, category } = event.target_data; + + // 生成唯一的模型ID + modelId = Date.now(); + modelName = name; + kernel.dropZone.recordModelPlacement(wallName, index, name + '_' + modelId); + + await kernel.model.add({ + modelName: name, + modelId: modelId, + modelUrl: file_url, + modelControlType: model_control_type, + drag: { + enable: true, + axis: rotation.y === 0 || rotation.y === 180 ? 'x' : 'z', + step: 0.1, + snapToZone: true, // 拖拽吸附到最近的分割区域 + returnWhenOutOfBounds: true, // 拖拽到区域外时返回原位置 + handleOccupiedZone: true, // 处理已占用区域(false=允许重叠) + occupiedZoneAction: 'replace' // 当开关3=true时的行为:'return'=返回原位置,'replace'=替换 + }, + transform: { + position: position, + rotation: rotation, + } + }); + + console.log(`百叶模型已放置为 ${name + '_' + modelId}`); + } + } // 第二次循环:处理 change_color(此时模型已加载完成) for (const event of result.data.events) { @@ -422,8 +444,8 @@ const getProductConfig = async (sku) => { } // API 配置 -//const API_BASE_URL = 'https://ztserver.zguiy.com'; -const API_BASE_URL = 'http://localhost:26517'; +const API_BASE_URL = 'https://ztserver.zguiy.com'; +//const API_BASE_URL = 'http://localhost:26517'; const getApiUrl = (path) => { return `${API_BASE_URL}${path}`; }; diff --git a/examples/demo-global.html b/examples/demo-global.html index c6e9afa..cc5929f 100644 --- a/examples/demo-global.html +++ b/examples/demo-global.html @@ -366,7 +366,7 @@