slvpartage:minetest_samples
Ceci est une ancienne révision du document !
copier le code suivant dans le site https://openjscad.xyz/
Ouvrez un nouvel onglet pour le site ( ouvrez l'url au dessus avec un clic droit , 'ouvrir dans un nouvel onglet')
Sur le site utilisez l'icône crayon pour afficher le code et cliquez une fois dedans pour voir apparaître les numéros de ligne.
Puis copier coller ( Ctrl + C ,Ctrl V ) le code suivant de cet onglet vers la fenêtre de code de l'autre.
/**
* Basic Text Creation
* @category Creating Shapes
* @skillLevel 10
* @description Demonstrating methods of building 3D text
* @tags text, font, characters
* @authors Simon Clark
* @licence MIT License
*/
const jscad = require('@jscad/modeling')
const { union } = jscad.booleans
const { extrudeLinear } = jscad.extrusions
const { hullChain } = jscad.hulls
const { circle, sphere } = jscad.primitives
const { vectorText } = jscad.text
const { translate } = jscad.transforms
const { cuboid, roundedCuboid } = require('@jscad/modeling').primitives
const getParameterDefinitions = () => {
return [
// { name: 'outline_string', initial: 'Outline', type: 'text', caption: 'Outline Text', size: 30 },
{ name: 'width', initial: 2, type: 'int', caption: 'width', size: 10 },
{ name: 'height', initial: 35, type: 'int', caption: 'height', size: 10 },
{ name: 'flat_string', initial: 'Flat', type: 'text', caption: 'Flat Text', size: 30 },
{ name: 'round_string', initial: 'Round', type: 'text', caption: 'Round Text', size: 30 }
]
}
const main = (params) => {
// const outlineText = buildOutlineText(params.outline_string, 2)
const flatText = buildFlatText(params.flat_string, params.width, params.width)
const roundText = buildRoundText(params.round_string, params.width)
const support = translate([params.height * 1.5 , - params.height / 4,0],cuboid({ size: [params.height * 3, params.height * 2, params.width / 2] }))
return [flatText, roundText, support]
}
// Build text by creating the font strokes (2D), then extruding up (3D).
const buildFlatText = (message, extrusionHeight, characterLineWidth) => {
if (message === undefined || message.length === 0) return []
const lineRadius = characterLineWidth / 2
const lineCorner = circle({ radius: lineRadius })
const lineSegmentPointArrays = vectorText({ x: 0, y: 0, input: message }) // line segments for each character
const lineSegments = []
lineSegmentPointArrays.forEach((segmentPoints) => { // process the line segment
const corners = segmentPoints.map((point) => translate(point, lineCorner))
lineSegments.push(hullChain(corners))
})
const message2D = union(lineSegments)
const message3D = extrudeLinear({ height: extrusionHeight }, message2D)
return translate([0, 0, 0], message3D)
}
// Build text by creating the font strokes (3D).
const buildRoundText = (message, p) => {
if (message === undefined || message.length === 0) return []
const lineRadius = p / 2
const lineCorner = sphere({ radius: lineRadius, center: [0, 0, lineRadius], segments: 16 })
const lineSegmentPointArrays = vectorText({ x: 0, y: 0, input: message }) // line segments for each character
const lineSegments = []
lineSegmentPointArrays.forEach((segmentPoints) => { // process the line segment
const corners = segmentPoints.map((point) => translate(point, lineCorner))
lineSegments.push(hullChain(corners))
})
const message3D = union(lineSegments)
return translate([0, -35, 0], message3D)
}
module.exports = { main, getParameterDefinitions }
worldedit
replace lava_flowing lava_source par air.
slvpartage/minetest_samples.1642603729.txt.gz · Dernière modification : de cyberyunohost
