Factory function to create Red Cube Apple in your world.

export function createAsset(THREE, options = {}) {
  const group = new THREE.Group();
  group.name = "Red Cube Apple";

  const scale = typeof options.scale === "number" ? options.scale : 1;
  const appleColor = options.appleColor || "#d94335";
  const centerColor = options.centerColor || "#f2c94c";
  const leafColor = options.leafColor || "#6fc46a";
  const leafVisible = options.leafVisible !== false;

  const redMat = new THREE.MeshStandardMaterial({ color: new THREE.Color(appleColor), roughness: 0.72, metalness: 0 });
  const goldMat = new THREE.MeshStandardMaterial({ color: new THREE.Color(centerColor), roughness: 0.52, metalness: 0.08 });
  const darkRedMat = new THREE.MeshStandardMaterial({ color: new THREE.Color("#b92f2d"), roughness: 0.78, metalness: 0 });
  const highlightMat = new THREE.MeshStandardMaterial({ color: new THREE.Color("#ff8a7c"), roughness: 0.65, metalness: 0 });
  const stemMat = new THREE.MeshStandardMaterial({ color: new THREE.Color("#8b5a2b"), roughness: 0.8, metalness: 0 });
  const leafMat = new THREE.MeshStandardMaterial({ color: new THREE.Color(leafColor), roughness: 0.7, metalness: 0 });

  function box(name, partId, size, position, material) {
    const mesh = new THREE.Mesh(new THREE.BoxGeometry(size[0], size[1], size[2]), material);
    mesh.name = name;
    mesh.position.set(position[0], position[1], position[2]);
    mesh.userData.partId = partId;
    group.add(mesh);
    return mesh;
  }

  box("apple center block", "apple_core", [1.0, 1.0, 1.0], [0, 0.45, 0], goldMat);
  box("apple left cheek", "apple_left_cheek", [0.38, 0.72, 0.86], [-0.62, 0.36, 0], redMat);
  box("apple right cheek", "apple_right_cheek", [0.38, 0.72, 0.86], [0.62, 0.36, 0], redMat);
  box("apple lower block", "apple_lower_block", [0.78, 0.34, 0.82], [0, -0.16, 0], darkRedMat);
  box("apple top dimple", "apple_top_dimple", [0.46, 0.18, 0.48], [0, 1.04, 0], darkRedMat);
  box("apple soft highlight", "apple_highlight", [0.24, 0.36, 0.08], [-0.28, 0.68, 0.52], highlightMat);
  box("apple stem", "apple_stem", [0.18, 0.44, 0.18], [0.08, 1.34, 0], stemMat);

  const leaf = box("apple leaf", "apple_leaf", [0.44, 0.16, 0.28], [0.42, 1.36, 0], leafMat);
  leaf.rotation.z = -0.38;
  leaf.visible = leafVisible;

  group.scale.setScalar(scale);
  return group;
}