mirror of
https://github.com/trafficlunar/blockmatic.git
synced 2026-06-28 06:34:13 +00:00
refactor: remove solid textures
This commit is contained in:
parent
dae3a88734
commit
f3441d8033
3 changed files with 6 additions and 51 deletions
|
|
@ -9,7 +9,6 @@ interface Props {
|
|||
blocks: Block[];
|
||||
missingTexture: PIXI.Texture | undefined;
|
||||
textures: Record<string, PIXI.Texture>;
|
||||
solidTextures: Record<string, PIXI.Texture>;
|
||||
coords: Position;
|
||||
scale: number;
|
||||
version: number;
|
||||
|
|
@ -18,7 +17,7 @@ interface Props {
|
|||
// Lifts 16,000 tiles limit
|
||||
settings.use32bitIndex = true;
|
||||
|
||||
function Blocks({ blocks, missingTexture, textures, solidTextures, coords, scale, version }: Props) {
|
||||
function Blocks({ blocks, missingTexture, textures, coords, scale, version }: Props) {
|
||||
const app = useApp();
|
||||
const tilemapRef = useRef<CompositeTilemap>();
|
||||
|
||||
|
|
@ -28,15 +27,9 @@ function Blocks({ blocks, missingTexture, textures, solidTextures, coords, scale
|
|||
tilemap.clear();
|
||||
|
||||
// Tile solid colors at smaller scales
|
||||
if (scale >= 0.4) {
|
||||
blocks.forEach((block) => {
|
||||
tilemap.tile(textures[block.name] ?? missingTexture, block.x * 16, block.y * 16);
|
||||
});
|
||||
} else {
|
||||
blocks.forEach((block) => {
|
||||
tilemap.tile(solidTextures[`${block.name}`] ?? missingTexture, block.x * 16, block.y * 16);
|
||||
});
|
||||
}
|
||||
blocks.forEach((block) => {
|
||||
tilemap.tile(textures[block.name] ?? missingTexture, block.x * 16, block.y * 16);
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ PIXI.settings.SCALE_MODE = PIXI.SCALE_MODES.NEAREST;
|
|||
function Canvas() {
|
||||
const { stageSize, canvasSize, blocks, coords, scale, version, setStageSize, setBlocks, setCoords, setScale } = useContext(CanvasContext);
|
||||
const { settings } = useContext(SettingsContext);
|
||||
const { missingTexture, solidTextures } = useContext(TexturesContext);
|
||||
const { missingTexture } = useContext(TexturesContext);
|
||||
const { isDark } = useContext(ThemeContext);
|
||||
const { tool, radius, selectedBlock, selectionCoords, cssCursor, setTool, setSelectedBlock, setSelectionCoords, setCssCursor } =
|
||||
useContext(ToolContext);
|
||||
|
|
@ -487,15 +487,7 @@ function Canvas() {
|
|||
onClick={onClick}
|
||||
options={{ backgroundAlpha: 0 }}
|
||||
>
|
||||
<Blocks
|
||||
blocks={visibleBlocks}
|
||||
missingTexture={missingTexture}
|
||||
textures={textures}
|
||||
solidTextures={solidTextures}
|
||||
coords={coords}
|
||||
scale={scale}
|
||||
version={version}
|
||||
/>
|
||||
<Blocks blocks={visibleBlocks} missingTexture={missingTexture} textures={textures} coords={coords} scale={scale} version={version} />
|
||||
|
||||
<Container x={coords.x} y={coords.y} scale={scale}>
|
||||
{settings.canvasBorder && <CanvasBorder canvasSize={canvasSize} isDark={isDark} />}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue