When a 3d node is addNodeData, the vertex graph of the same type as the new add data in the original data will not be visible #6567
xiaoxiaofu1 posted onGitHub
Describe the bug / 问题描述
如下添加node-8后,node-1的图形会看不到
Reproduction link / 重现链接
No response
Steps to Reproduce the Bug or Issue / 重现步骤
import { ExtensionCategory, Graph, register } from '@antv/g6'; import { Capsule, Cone, Cube, Cylinder, Light, ObserveCanvas3D, Plane, Sphere, Torus, renderer, } from '@antv/g6-extension-3d';
register(ExtensionCategory.PLUGIN, '3d-light', Light); register(ExtensionCategory.NODE, 'sphere', Sphere); register(ExtensionCategory.NODE, 'plane', Plane); register(ExtensionCategory.NODE, 'cylinder', Cylinder); register(ExtensionCategory.NODE, 'cone', Cone); register(ExtensionCategory.NODE, 'cube', Cube); register(ExtensionCategory.NODE, 'capsule', Capsule); register(ExtensionCategory.NODE, 'torus', Torus); register(ExtensionCategory.BEHAVIOR, 'observe-canvas-3d', ObserveCanvas3D);
const nodes = [ { id: 'node-1', type: 'sphere', style: { texture: 'https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*cdTdTI2bNl8AAAAAAAAAAAAADmJ7AQ/original', }, }, { id: 'node-2', type: 'plane', style: { size: 50 } }, { id: 'node-3', type: 'cylinder' }, { id: 'node-4', type: 'cone' }, { id: 'node-5', type: 'cube', style: { texture: 'https://gw.alipayobjects.com/mdn/rms_6ae20b/afts/img/A*8TlCRIsKeUkAAAAAAAAAAAAAARQnAQ', }, }, { id: 'node-6', type: 'capsule' }, { id: 'node-7', type: 'torus' },
];
const graph = new Graph({ container: 'container', renderer, data: { nodes, }, node: { style: { materialType: 'phong', labelText: (d) => d.id, x: (d) => 100 + (nodes.findIndex((n) => n.id === d.id) % 5) * 100, y: (d) => 100 + Math.floor(nodes.findIndex((n) => n.id === d.id) / 5) * 100, }, }, plugins: [ { type: '3d-light', directional: { direction: [0, 0, 1], }, }, ], behaviors: ['observe-canvas-3d'], });
graph.render(); setTimeout(() => { graph.addNodeData([ { id: 'node-8', type: 'sphere' }]) graph.draw() }, 1000)
G6 Version / G6 版本
🆕 5.x
Operating System / 操作系统
macOS
Browser / 浏览器
Chrome
Additional context / 补充说明
No response