修改粗糙金属度
This commit is contained in:
@ -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.5, rotationY: 0.3, background: false },
|
||||
env: { envPath: 'https://cdn.files.zguiy.com/zt/environment.env', intensity: 1.2, rotationY: 0.3, background: false },
|
||||
gizmo: {
|
||||
position: false,
|
||||
rotation: false,
|
||||
@ -362,14 +362,16 @@ const executeEvent2 = async (result, sku) => {
|
||||
for (const event of result.data.events) {
|
||||
if (event.event_type === 'change_color') {
|
||||
const materialName = event.material_name;
|
||||
console.log('替换模型颜色:', event);
|
||||
const { color, color_map_url, normal_map_url, metallic, roughness } = event.target_data;
|
||||
console.log('替换模型颜色:', event.target_data);
|
||||
|
||||
|
||||
kernel.material.apply({
|
||||
target: materialName,
|
||||
albedoColor: color,
|
||||
albedoTexture: color_map_url,
|
||||
normalMap: normal_map_url,
|
||||
|
||||
});
|
||||
|
||||
console.log(`百叶模型颜色已替换为 ${color}`);
|
||||
|
||||
@ -585,7 +585,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://sdk.zguiy.com/zt/assets/index.global.js?v=1234"></script>
|
||||
<!-- <script src="https://sdk.zguiy.com/zt/assets/index.global.js?v=1234"></script> -->
|
||||
<script src="./index.global.js?v=1234"></script>
|
||||
<script src="./app-global.js"></script>
|
||||
<script>
|
||||
// 从全局对象获取 SDK kernel
|
||||
|
||||
@ -29855,6 +29855,10 @@ var kernel = (function (exports) {
|
||||
rotationY: 0,
|
||||
background: false
|
||||
},
|
||||
camera: {
|
||||
position: { x: 0, y: 2, z: 5 },
|
||||
target: { x: 0, y: 1, z: 0 }
|
||||
},
|
||||
gizmo: {
|
||||
position: true,
|
||||
rotation: false,
|
||||
@ -70348,14 +70352,22 @@ var kernel = (function (exports) {
|
||||
const scene = this.mainApp.appScene.object;
|
||||
const canvas = AppConfig.container;
|
||||
if (!scene || !canvas) return;
|
||||
this.object = new ArcRotateCamera("Camera", Tools.ToRadians(70), Tools.ToRadians(85), 5, new Vector3(0, 2, 0), scene);
|
||||
const { position, target } = AppConfig.camera;
|
||||
this.object = new ArcRotateCamera(
|
||||
"Camera",
|
||||
Tools.ToRadians(70),
|
||||
Tools.ToRadians(85),
|
||||
5,
|
||||
new Vector3(target.x, target.y, target.z),
|
||||
scene
|
||||
);
|
||||
this.object.attachControl(canvas, true);
|
||||
this.object.minZ = 0.01;
|
||||
this.object.wheelPrecision = 200;
|
||||
this.object.panningSensibility = 0;
|
||||
this.object.upperBetaLimit = Tools.ToRadians(90);
|
||||
this.object.position = new Vector3(0, 0, 10);
|
||||
this.setTarget(0, 0.5, 0);
|
||||
this.object.position = new Vector3(position.x, position.y, position.z);
|
||||
this.setTarget(target.x, target.y, target.z);
|
||||
}
|
||||
/** 设置相机目标点 */
|
||||
setTarget(x, y, z) {
|
||||
@ -354678,16 +354690,6 @@ clipPos=viewProjection*worldPos;previousClipPos=previousViewProjection*previousW
|
||||
});
|
||||
return min.add(max).scaleInPlace(0.5);
|
||||
}
|
||||
setupShadows(meshes) {
|
||||
const appLight = this.mainApp.appLight;
|
||||
if (!appLight) return;
|
||||
meshes.forEach((mesh) => {
|
||||
if (mesh.getTotalVertices() > 0) {
|
||||
appLight.addShadowCaster(mesh);
|
||||
mesh.receiveShadows = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
/** 获取缓存的网格 */
|
||||
getCachedMeshes(name) {
|
||||
return this.modelDic.Get(name);
|
||||
@ -355956,6 +355958,8 @@ clipPos=viewProjection*worldPos;previousClipPos=previousViewProjection*previousW
|
||||
material.albedoTexture = null;
|
||||
}
|
||||
}
|
||||
material.roughness = 0.8;
|
||||
material.metallic = 0;
|
||||
material.markDirty();
|
||||
});
|
||||
}
|
||||
@ -358085,9 +358089,6 @@ clipPos=viewProjection*worldPos;previousClipPos=previousViewProjection*previousW
|
||||
if (this.config.position) {
|
||||
this.ground.position = this.config.position;
|
||||
}
|
||||
if (this.config.receiveShadows) {
|
||||
this.ground.receiveShadows = true;
|
||||
}
|
||||
this.ground.isPickable = false;
|
||||
}
|
||||
/** 创建材质 */
|
||||
@ -358226,6 +358227,7 @@ clipPos=viewProjection*worldPos;previousClipPos=previousViewProjection*previousW
|
||||
AppConfig.container = config.container;
|
||||
AppConfig.modelUrlList = config.modelUrlList || [];
|
||||
AppConfig.env = { ...AppConfig.env, ...config.env || {} };
|
||||
AppConfig.camera = { ...AppConfig.camera, ...config.camera || {} };
|
||||
AppConfig.gizmo = { ...AppConfig.gizmo, ...config.gizmo || {} };
|
||||
AppConfig.outline = { ...AppConfig.outline, ...config.outline || {} };
|
||||
this.appPositionGizmo.configure(AppConfig.gizmo);
|
||||
@ -358362,6 +358364,7 @@ clipPos=viewProjection*worldPos;previousClipPos=previousViewProjection*previousW
|
||||
* @param options 材质应用选项
|
||||
*/
|
||||
apply: (options) => {
|
||||
console.log(options);
|
||||
this.mainApp.gameManager.applyMaterial(options);
|
||||
}
|
||||
};
|
||||
@ -358704,6 +358707,7 @@ clipPos=viewProjection*worldPos;previousClipPos=previousViewProjection*previousW
|
||||
container,
|
||||
modelUrlList: params.modelUrlList || [],
|
||||
env: params.env,
|
||||
camera: params.camera,
|
||||
gizmo: params.gizmo,
|
||||
outline: params.outline
|
||||
});
|
||||
|
||||
360233
examples/index.js
360233
examples/index.js
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user