截图中的墙,通过GLB格式导出后,导入到小程序xr-frame中,会显示一个黑不溜秋的东西,很难调节。
截图中的管子,通过点位数据导出,通过registerGeometry插入,会变成一个另类的东西。
【后面的那个白色就是那个管子】
附上插入代码【在xr-basic例子中插入】:
const xr = wx.getXrFrameSystem();
const xrScene = this.scene = detail.value;
let scene = xrScene;
console.log('xr-scene', xrScene);
let defaultVertexLayoutInfo = {
attributes: [
{
name: "a_position",
format: xr.EVertexFormat.FLOAT3,
offset: 0,
usage: xr.EVertexLayoutUsage.POSITION
},
{
name: "a_normal",
format: xr.EVertexFormat.FLOAT3,
offset: 12,
usage: xr.EVertexLayoutUsage.NORMAL,
},
{
name: "a_texCoord",
format: xr.EVertexFormat.FLOAT2,
offset: 24,
usage: xr.EVertexLayoutUsage.UV0
},
{
name: "a_color",
format: xr.EVertexFormat.FLOAT4,
offset: 32,
usage: xr.EVertexLayoutUsage.COLOR
}
],
stride: 48
};
let vertexs = [];
let indices = [];
vertexs.push(...[-0.0015113172000000002, 0.0143994946, -0.047332552, 0.030442, -0.468643, -0.882863, 0.75, 1, 1, 1, 1, 1, 0.004940709600000001, -0.0470739829, -0.014478588400000002, 0.198291, -0.914063, -0.353793, 1, 0.968106, 1, 1, 1, 1, 0.0015113172000000002, -0.0143994946, 0.047332552, 0.187446, -0.864073, 0.467164, 0.5, 1, 1, 1, 1, 1, -0.004940709600000001, 0.0470739829, 0.014478588400000002, 0.140296, -0.987724, 0.06869, 0.75, 0.968106, 1, 1, 1, 1, 0.3285223183, 0.0358379627, -0.047332552, -0.066037, 0.46492, 0.882886, 0.25, 1, 1, 1, 1, 1, 0.39032958770000004, 0.036529722900000006, -0.014478588400000002, 0.038404, 0.994907, -0.093196, 0.5, 0.968106, 1, 1, 1, 1, 0.3574776817, 0.0361620373, 0.047332552, 0.034136, 0.884344, -0.465586, 0, 1, 1, 1, 1, 1, 0.2956704123, 0.0354702771, 0.014478588400000002, -0.064795, 0.997491, -0.028504, 0.25, 0.968106, 1, 1, 1, 1, -0.055189746100000006, 4.0988116985000005, -0.047332552, 0.468519, 0.044248, -0.882344, 0.75, 0.968106, 1, 1, 1, 1, -0.0159574213, 4.146576139, -0.014478588400000002, 0.597653, 0.059079, -0.799575, 1, 0.589638, 1, 1, 1, 1, -0.0368102539, 4.1211883015, 0.047332552, 0.879471, 0.086938, 0.467946, 0.5, 0.968106, 1, 1, 1, 1, -0.0760425787, 4.073423861, 0.014478588400000002, 0.931917, 0.089949, 0.35134, 0.75, 0.589638, 1, 1, 1, 1, -4.6125701023, 4.096215750700001, -0.047332552, -0.46849, -0.045219, 0.882311, 0.25, 0.968106, 1, 1, 1, 1, -4.6314819616000005, 4.1550626593, -0.014478588400000002, -0.600626, -0.05529, 0.797616, 0.5, 0.589638, 1, 1, 1, 1, -4.6214298977, 4.1237842493, 0.047332552, -0.879927, -0.081002, -0.468153, 0, 0.968106, 1, 1, 1, 1, -4.6025180384, 4.0649373407, 0.014478588400000002, -0.932338, -0.088051, -0.350703, 0.25, 0.589638, 1, 1, 1, 1, -4.602885902000001, 2.6442282756, -0.047332552, -0.000323, 0.566895, -0.82379, 0.75, 0.589638, 1, 1, 1, 1, -4.6631409809, 2.6304463107, -0.014478588400000002, 0.000897, 0.487689, -0.873017, 1, 0.166922, 1, 1, 1, 1, -4.6311140979, 2.6377717244000003, 0.047332552, 0.0017, 0.924811, 0.380423, 0.5, 0.589638, 1, 1, 1, 1, -4.5708590191, 2.6515536893, 0.014478588400000002, 0.000505, 0.892297, 0.451449, 0.75, 0.166922, 1, 1, 1, 1, -4.281000000000001, 2.6554785884000003, -0.047332552, -0.000321, -0.566, 0.824037, 0.25, 0.589638, 1, 1, 1, 1, -4.281000000000001, 2.593667448, -0.014478588400000002, 0.000914, -0.487246, 0.873264, 0.5, 0.166922, 1, 1, 1, 1, -4.281000000000001, 2.6265214116, 0.047332552, 0.001735, -0.925218, -0.379432, 0, 0.589638, 1, 1, 1, 1, -4.281000000000001, 2.688332552, 0.014478588400000002, 0.000508, -0.892231, -0.45158, 0.25, 0.166922, 1, 1, 1, 1, 0.0005447911999999999, -0.0051906495, -0.0497268575, -0.871118, -0.00581, -0.491039, 0.75, 0.166922, 1, 1, 1, 1, 0.004055558, -0.0386404558, -0.0314716956, -0.480447, 0.009977, -0.876967, 1, 0.031072, 1, 1, 1, 1, 0.0051906342000000005, -0.0494552092, 0.005219157, -0.985135, 0.020457, 0.17056, 0.5, 0.166922, 1, 1, 1, 1, 0.0032851075000000004, -0.0312997745, 0.038852698600000006, -0.888157, 0.005788, 0.459504, 0.75, 0.031072, 1, 1, 1, 1, -0.0005447904000000001, 0.0051906419, 0.0497268583, 0.86227, -0.005619, 0.506417, 0.25, 0.166922, 1, 1, 1, 1, -0.0040555575, 0.038640451000000006, 0.0314717016, 0.476801, 0.01068, 0.878946, 0.5, 0.031072, 1, 1, 1, 1, -0.0051906343, 0.04945521, -0.0052191494, 0.988506, 0.022142, -0.149552, 0, 0.166922, 1, 1, 1, 1, -0.0032851081, 0.0312997804, -0.038852693699999996, 0.887589, 0.00592, -0.460598, 0.25, 0.031072, 1, 1, 1, 1, 0.34821883400000003, 0.0360584103, -0.0497268575, 0.032915, -0.941753, -0.33469, 0.75, 0.031072, 1, 1, 1, 1, 0.3818502678, 0.0364348205, -0.0314716956, -0.045125, -0.468864, -0.882117, 1, 0, 1, 1, 1, 1, 0.3927, 0.0365565188, 0.005219157, -0.094484, -0.981707, 0.165301, 0.5, 0.031072, 1, 1, 1, 1, 0.3744697276, 0.0363522159, 0.038852698600000006, -0.028363, -0.882661, 0.469154, 0.75, 0, 1, 1, 1, 1, 0.3377811737, 0.03594158980000001, 0.0497268583, 0.028975, 0.901698, 0.431395, 0.25, 0.031072, 1, 1, 1, 1, 0.3041497371, 0.0355651795, 0.0314717016, -0.059447, 0.468512, 0.881455, 0.5, 0, 1, 1, 1, 1, 0.29327625549999997, 0.0354434812, -0.0052191494, -0.125704, 0.990689, -0.052277, 0, 0.031072, 1, 1, 1, 1, 0.3115302664, 0.035647784, -0.038852693699999996, -0.030848, 0.882596, -0.469119, 0.25, 0, 1, 1, 1, 1, -0.0426873316, 4.1140330966, -0.0497268575, -0.994537, -0.104383, 0, -0.212237, -0.5, 1, 1, 1, 1, -0.0213396917, 4.140023350400001, -0.0314716956, -0.994537, -0.104383, 0, -0.212237, -0.5, 1, 1, 1, 1, -0.014437724600000002, 4.1484263343, 0.005219157, 1, 0, 0, 0.212237, -0.5, 1, 1, 1, 1, -0.026024508700000004, 4.1343196949, 0.038852698600000006, 1, 0, 0, 0.212237, -0.5, 1, 1, 1, 1, -0.04931266360000001, 4.1059669093, 0.0497268583, 0.056206, -0.473741, -0.878869, 0.875, 1, 1, 1, 1, 1, -0.0706603053, 4.0799766534, 0.0314717016, 0.184598, -0.928938, -0.320931, 1, 0, 1, 1, 1, 1, -0.0775622759, 4.071573665, -0.0052191494, 0.186937, -0.940708, -0.28306, 0.75, 1, 1, 1, 1, 1, -0.0659754951, 4.0856803005, -0.038852693699999996, 0.216273, -0.974434, -0.060861, 0.875, 0.968106, 1, 1, 1, 1, -4.618596864800001, 4.1149688694, -0.0497268575, 0.190712, -0.85927, 0.47464, 0.625, 1, 1, 1, 1, 1, -4.6288874496, 4.1469894703, -0.0314716956, 0.178563, -0.979715, 0.090961, 0.75, 0.968106, 1, 1, 1, 1, -4.6322145282, 4.1573421433, 0.005219157, 0.051085, -0.280288, 0.958556, 0.5, 1, 1, 1, 1, 1, -4.6266291434, 4.1399624333, 0.038852698600000006, 0.087437, -0.961998, 0.25868, 0.625, 0.968106, 1, 1, 1, 1, -4.6154031375, 4.1050311379, 0.0497268583, -0.043183, 0.475108, 0.878867, 0.375, 1, 1, 1, 1, 1, -4.6051125519000005, 4.073010534300001, 0.0314717016, 0.00997, 0.999191, -0.03897, 0.5, 0.968106, 1, 1, 1, 1, -4.6017854715, 4.0626578559, -0.0052191494, 0.009571, 0.959237, 0.282442, 0.25, 1, 1, 1, 1, 1, -4.6073708548, 4.080037561, -0.038852693699999996, 0.046887, 0.998752, -0.017208, 0.375, 0.968106, 1, 1, 1, 1, -4.6220877713, 2.6398362892000002, -0.0497268575, 0.041322, 0.880204, -0.472794, 0.125, 1, 1, 1, 1, 1, -4.654874605500001, 2.6323370542, -0.0314716956, -0.01381, 0.999904, -0.001421, 0.25, 0.968106, 1, 1, 1, 1, -4.665475011500001, 2.6299124548, 0.005219157, -0.003939, 0.285207, -0.958458, 0, 1, 1, 1, 1, 1, -4.6476794158, 2.6339827885, 0.038852698600000006, -0.110852, 0.934333, -0.338724, 0.125, 0.968106, 1, 1, 1, 1, -4.6119122361, 2.6421637091, 0.0497268583, 0.476162, 0.045644, -0.878172, 0.875, 0.968106, 1, 1, 1, 1, -4.5791253992, 2.6496629448, 0.0314717016, 0.605906, 0.059532, -0.793306, 1, 0.589638, 1, 1, 1, 1, -4.5685249877, 2.6520875454, -0.0052191494, 0.954473, 0.09378, -0.283173, 0.75, 0.968106, 1, 1, 1, 1, -4.5863205783, 2.6480172129, -0.038852693699999996, 0.973937, 0.09644, -0.205295, 0.875, 0.589638, 1, 1, 1, 1, -4.281000000000001, 2.6357808392, -0.0497268575, 0.875371, 0.08668, 0.4756, 0.625, 0.968106, 1, 1, 1, 1, -4.281000000000001, 2.602147299, -0.0314716956, 0.929216, 0.090812, 0.358204, 0.75, 0.589638, 1, 1, 1, 1, -4.281000000000001, 2.5912731421000004, 0.005219157, 0.283777, 0.027734, 0.958489, 0.5, 0.968106, 1, 1, 1, 1, -4.281000000000001, 2.6095283014, 0.038852698600000006, 0.385782, 0.036691, 0.92186, 0.625, 0.589638, 1, 1, 1, 1, -4.281000000000001, 2.6462191532, 0.0497268583, -0.476172, -0.045288, 0.878185, 0.375, 0.968106, 1, 1, 1, 1, -4.281000000000001, 2.6798526961, 0.0314717016, -0.608346, -0.056378, 0.791667, 0.5, 0.589638, 1, 1, 1, 1, -4.281000000000001, 2.6907268587, -0.0052191494, -0.954941, -0.088498, 0.283294, 0.25, 0.968106, 1, 1, 1, 1, -4.281000000000001, 2.6724717046000004, -0.038852693699999996, -0.974885, -0.089572, 0.203901, 0.375, 0.589638, 1, 1, 1, 1])
indices.push(...[1, 4, 0, 4, 1, 5, 2, 5, 1, 5, 2, 6, 3, 6, 2, 6, 3, 7, 0, 7, 3, 7, 0, 4, 5, 8, 4, 8, 5, 9, 6, 9, 5, 9, 6, 10, 7, 10, 6, 10, 7, 11, 4, 11, 7, 11, 4, 8, 9, 12, 8, 12, 9, 13, 10, 13, 9, 13, 10, 14, 11, 14, 10, 14, 11, 15, 8, 15, 11, 15, 8, 12, 13, 16, 12, 16, 13, 17, 14, 17, 13, 17, 14, 18, 15, 18, 14, 18, 15, 19, 12, 19, 15, 19, 12, 16, 17, 20, 16, 20, 17, 21, 18, 21, 17, 21, 18, 22, 19, 22, 18, 22, 19, 23, 16, 23, 19, 23, 16, 20, 1, 0, 3, 1, 3, 2, 21, 23, 20, 21, 22, 23, 25, 32, 24, 32, 25, 33, 26, 33, 25, 33, 26, 34, 27, 34, 26, 34, 27, 35, 28, 35, 27, 35, 28, 36, 29, 36, 28, 36, 29, 37, 30, 37, 29, 37, 30, 38, 31, 38, 30, 38, 31, 39, 24, 39, 31, 39, 24, 32, 33, 40, 32, 40, 33, 41, 34, 41, 33, 41, 34, 42, 35, 42, 34, 42, 35, 43, 36, 43, 35, 43, 36, 44, 37, 44, 36, 44, 37, 4, 38, 45, 37, 45, 38, 46, 39, 46, 38, 46, 39, 47, 32, 47, 39, 47, 32, 40, 41, 48, 40, 48, 41, 49, 42, 49, 41, 49, 42, 50, 43, 50, 42, 50, 43, 51, 44, 51, 43, 51, 44, 52, 45, 52, 44, 52, 45, 53, 46, 53, 45, 53, 46, 54, 47, 54, 46, 54, 47, 55, 40, 55, 47, 55, 40, 48, 49, 56, 48, 56, 49, 57, 50, 57, 49, 57, 50, 58, 51, 58, 50, 58, 51, 59, 52, 59, 51, 59, 52, 60, 53, 60, 52, 60, 53, 61, 54, 61, 53, 61, 54, 62, 55, 62, 54, 62, 55, 63, 48, 63, 55, 63, 48, 56, 57, 64, 56, 64, 57, 65, 58, 65, 57, 65, 58, 66, 59, 66, 58, 66, 59, 67, 60, 67, 59, 67, 60, 68, 61, 68, 60, 68, 61, 69, 62, 69, 61, 69, 62, 70, 63, 70, 62, 70, 63, 71, 56, 71, 63, 71, 56, 64, 25, 24, 31, 25, 31, 30, 25, 30, 29, 25, 29, 28, 25, 28, 27, 25, 27, 26, 65, 71, 64, 65, 70, 71, 65, 69, 70, 65, 68, 69, 65, 67, 68, 65, 66, 67, 1, 4, 0, 4, 1, 5, 2, 5, 1, 5, 2, 6, 3, 6, 2, 6, 3, 7, 0, 7, 3, 7, 0, 4, 5, 8, 4, 8, 5, 9, 6, 9, 5, 9, 6, 10, 7, 10, 6, 10, 7, 11, 4, 11, 7, 11, 4, 8, 9, 12, 8, 12, 9, 13, 10, 13, 9, 13, 10, 14, 11, 14, 10, 14, 11, 15, 8, 15, 11, 15, 8, 12, 13, 16, 12, 16, 13, 17, 14, 17, 13, 17, 14, 18, 15, 18, 14, 18, 15, 19, 12, 19, 15, 19, 12, 16, 17, 20, 16, 20, 17, 21, 18, 21, 17, 21, 18, 22, 19, 22, 18, 22, 19, 23, 16, 23, 19, 23, 16, 20, 1, 0, 3, 1, 3, 2, 21, 23, 20, 21, 22, 23, 25, 32, 24, 32, 25, 33, 26, 33, 25, 33, 26, 34, 27, 34, 26, 34, 27, 35, 28, 35, 27, 35, 28, 36, 29, 36, 28, 36, 29, 37, 30, 37, 29, 37, 30, 38, 31, 38, 30, 38, 31, 39, 24, 39, 31, 39, 24, 32, 33, 40, 32, 40, 33, 41, 34, 41, 33, 41, 34, 42, 35, 42, 34, 42, 35, 43, 36, 43, 35, 43, 36, 44, 37, 44, 36, 44, 37, 45, 38, 45, 37, 45, 38, 46, 39, 46, 38, 4, 39, 47, 32, 47, 39, 47, 32, 40, 41, 48, 40, 48, 41, 49, 42, 49, 41, 49, 42, 50, 43, 50, 42, 50, 43, 51, 44, 51, 43, 51, 44, 52, 45, 52, 44, 52, 45, 53, 46, 53, 45, 53, 46, 54, 47, 54, 46, 54, 47, 55, 40, 55, 47, 55, 40, 48, 49, 56, 48, 56, 49, 57, 50, 57, 49, 57, 50, 58, 51, 58, 50, 58, 51, 59, 52, 59, 51, 59, 52, 60, 53, 60, 52, 60, 53, 61, 54, 61, 53, 61, 54, 62, 55, 62, 54, 62, 55, 63, 48, 63, 55, 63, 48, 56, 57, 64, 56, 64, 57, 65, 58, 65, 57, 65, 58, 66, 59, 66, 58, 66, 59, 67, 60, 67, 59, 67, 60, 68, 61, 68, 60, 68, 61, 69, 62, 69, 61, 69, 62, 70, 63, 70, 62, 70, 63, 71, 56, 71, 63, 71, 56, 64, 25, 24, 31, 25, 31, 30, 25, 30, 29, 25, 29, 28, 25, 28, 27, 25, 27, 26, 65, 71, 64, 65, 70, 71, 65, 69, 70, 65, 68, 69, 65, 67, 68, 65, 66, 67]);
const vl = scene.createVertexLayout(defaultVertexLayoutInfo);
const vb = new Float32Array(vertexs);
const ib = new Uint16Array(indices);
const geometry = scene.createGeometry(vl, vb, ib);
geometry.addSubMesh(ib.length, 0, 0);
xr.registerGeometry("man", scene => {
return geometry;
});
let ele = scene.createElement(xr.XRMesh, {
geometry: "man",
material: "standard-mat",
scale: "10 10 10",
position: "0 0 0"
});
let geometryRoot = scene.getElementById("node");
geometryRoot.addChild(ele);
另外希望能够提供:ExtrudeGeometry等基础类,不然不如three方便,但是three小程序兼容性比较差【即使改造后】。
glb那个可以私发我看下,我没太清楚具体问题。
registerGeometry的话,我估计是用法上的差异(应该可以,不过要注意顶点格式与顺序、饶序)。
可以参考下 模版 - 自定义Geometry